Skip to content

Commit

Permalink
Fix timeout issue & Set environment correctly on windows
Browse files Browse the repository at this point in the history
- the shell option is needed for spawn to access windows shell commands, exec does this by default but exec does not capture detailed output streams

- fix a timeout where ms was used as seconds

- note that you need to restart for telemetry notice to change
  • Loading branch information
nagilson committed Oct 19, 2023
1 parent 1a83c40 commit 72f60df
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion vscode-dotnet-runtime-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"dotnetAcquisitionExtension.enableTelemetry": {
"type": "boolean",
"default": true,
"description": "Enable Telemetry for the .NET Runtime Install Tool"
"description": "Enable Telemetry for the .NET Runtime Install Tool. Restart VS Code to apply changes."
},
"dotnetAcquisitionExtension.installTimeoutValue": {
"type": "number",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ Please report this issue so it can be remedied or investigated.`));
*/
private async fetchJsonObjectFromUrl(url : string)
{
const webWorker = this.customWebRequestWorker ? this.customWebRequestWorker : new WebRequestWorker(this.extensionState, this.eventStream, url, this.timeoutSecs, this.proxyUrl);
const webWorker = this.customWebRequestWorker ? this.customWebRequestWorker : new WebRequestWorker(this.extensionState, this.eventStream, url, this.timeoutSecs * 1000, this.proxyUrl);
return webWorker.getCachedData();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { FileUtilities } from '../Utils/FileUtilities';
import { IGlobalInstaller } from './IGlobalInstaller';
import { IAcquisitionWorkerContext } from './IAcquisitionWorkerContext';
import { VersionResolver } from './VersionResolver';
import { DotnetAcquisitionDistroUnknownError, DotnetAcquisitionError, DotnetConflictingGlobalWindowsInstallError, DotnetUnexpectedInstallerOSError, OSXOpenNotAvailableError } from '../EventStream/EventStreamEvents';
import { DotnetAcquisitionDistroUnknownError, DotnetAcquisitionError, DotnetConflictingGlobalWindowsInstallError, DotnetUnexpectedInstallerOSError, OSXOpenNotAvailableError, SuppressedAcquisitionError } from '../EventStream/EventStreamEvents';
import { ICommandExecutor } from '../Utils/ICommandExecutor';
import { CommandExecutor } from '../Utils/CommandExecutor';
import exp = require('constants');
Expand Down Expand Up @@ -125,6 +125,14 @@ We cannot verify .NET is safe to download at this time. Please try again later.`
}

await this.webWorker.downloadFile(installerUrl, installerPath);
try
{
fs.chmodSync(installerPath, 0o744);
}
catch(error : any)
{
this.acquisitionContext.eventStream.post(new SuppressedAcquisitionError(error, `Failed to chmod +x on ${installerPath}.`));
}
return installerPath;
}

Expand Down
23 changes: 10 additions & 13 deletions vscode-dotnet-runtime-library/src/Utils/CommandExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Please install the .NET SDK manually by following https://learn.microsoft.com/en
{
if(!options)
{
options = {cwd : path.resolve(__dirname)};
options = {cwd : path.resolve(__dirname), shell: os.platform() === 'win32'};
}

const splitCommands : string[] = command.split('&&');
Expand Down Expand Up @@ -226,34 +226,31 @@ out: ${commandResult.stdout} err: ${commandResult.stderr}.`));
const setSystemVariable = `setx ${variable} "${value}"`;
try
{
environmentEditExitCode = environmentEditExitCode || Number((await this.execute(setShellVariable))[0]);
environmentEditExitCode = environmentEditExitCode || Number((await this.execute(setSystemVariable))[0]);
const shellEditResponse = await this.execute(setShellVariable);
environmentEditExitCode += Number(shellEditResponse[0]);
const systemEditResponse = await this.execute(setSystemVariable)
environmentEditExitCode += Number(systemEditResponse[0]);
}
catch(error)
{
if(failureWarningMessage)
{
new WindowDisplayWorker().showWarningMessage(failureWarningMessage, () => {/* No Callback */}, );
}
environmentEditExitCode = 1
}
}
else
{
const setVariable = `${variable}=${value} && export ${variable}`
try
{
environmentEditExitCode = environmentEditExitCode || Number((await this.execute(setVariable))[0]);;
const environmentEditResponse = await this.execute(setVariable)
environmentEditExitCode += Number(environmentEditResponse[0]);
}
catch(error)
{
if(failureWarningMessage)
{
new WindowDisplayWorker().showWarningMessage(failureWarningMessage, () => {/* No Callback */}, );
}
environmentEditExitCode = 1;
}
}

if(environmentEditExitCode && failureWarningMessage)
if(environmentEditExitCode !== 0 && failureWarningMessage)
{
new WindowDisplayWorker().showWarningMessage(failureWarningMessage, () => {/* No Callback */}, );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class WebRequestWorker
...(keepAlive && {headers: { 'Connection': 'keep-alive' }}),
...(this.proxyEnabled() && {proxy : false}),
...(this.proxyEnabled() && {httpsAgent : this.proxyAgent}),
...furtherOptions,
...furtherOptions
};

return options;
Expand Down
2 changes: 1 addition & 1 deletion vscode-dotnet-sdk-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"dotnetSDKAcquisitionExtension.enableTelemetry": {
"type": "boolean",
"default": true,
"description": "Enable Telemetry for the .NET SDK Install Tool."
"description": "Enable Telemetry for the .NET SDK Install Tool. Restart VS Code to apply changes."
},
"dotnetSDKAcquisitionExtension.installTimeoutValue": {
"type": "number",
Expand Down

0 comments on commit 72f60df

Please sign in to comment.