Skip to content

Commit

Permalink
Fix issue 3709 (#3712)
Browse files Browse the repository at this point in the history
* Fix issue 3709

Fixes #3709 by:
- increasing the timeout to 20 seconds (the previous 10 seconds might be a bit short in a case of a freshly-started machine with low RAM and slow disk)
- improving error handling in case a process is terminated due to a signal
  • Loading branch information
karolz-ms authored Nov 28, 2022
1 parent 1fa4108 commit 8ed278b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/runtimes/docker/utils/spawnStreamAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ export async function spawnStreamAsync(
disposable.dispose();
if (code === 0) {
resolve();
} else if (signal) {
reject(new ChildProcessError(`Process exited due to signal ${signal}`, code, signal));
} else {
reject(new ChildProcessError(`Process exited with code ${code}`, code, signal));
}
Expand Down
11 changes: 9 additions & 2 deletions src/utils/netCoreUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ext } from '../extensionVariables';
import { localize } from '../localize';
import { getTempFileName } from './osUtils';
import { execAsync } from './execAsync';
import { parseError } from '@microsoft/vscode-azext-utils';

export async function getNetCoreProjectInfo(target: 'GetBlazorManifestLocations' | 'GetProjectProperties', project: string): Promise<string[]> {
const targetsFile = path.join(ext.context.asAbsolutePath('resources'), 'netCore', `${target}.targets`);
Expand All @@ -17,7 +18,13 @@ export async function getNetCoreProjectInfo(target: 'GetBlazorManifestLocations'
const command = `dotnet build /r:false /t:${target} /p:CustomAfterMicrosoftCommonTargets="${targetsFile}" /p:CustomAfterMicrosoftCommonCrossTargetingTargets="${targetsFile}" /p:InfoOutputPath="${outputFile}" "${project}"`;

try {
await execAsync(command, { timeout: 10000 });
try {
await execAsync(command, { timeout: 20000 });
} catch (err) {
const error = parseError(err);
throw new Error(localize('vscode-docker.netCoreUtils.noProjectInfo', 'Unable to determine project information for target \'{0}\' on project \'{1}\' {2}', target, project, error.message));
}


if (await fse.pathExists(outputFile)) {
const contents = await fse.readFile(outputFile, 'utf-8');
Expand All @@ -27,7 +34,7 @@ export async function getNetCoreProjectInfo(target: 'GetBlazorManifestLocations'
}
}

throw new Error(localize('vscode-docker.netCoreUtils.noProjectInfo', 'Unable to determine project information for target \'{0}\' on project \'{1}\'', target, project));
throw new Error(localize('vscode-docker.netCoreUtils.noProjectInfo2', 'Unable to determine project information for target \'{0}\' on project \'{1}\'', target, project));
} finally {
if (await fse.pathExists(outputFile)) {
await fse.unlink(outputFile);
Expand Down

0 comments on commit 8ed278b

Please sign in to comment.