Skip to content

Commit bf4639a

Browse files
clydindgp1130
authored andcommitted
fix(@angular-devkit/build-angular): prevent hanging initial build during exception with esbuild
When using the experimental esbuild-based browser application builder and an exception is thrown during the initial build, the process may hang indefinitely due to the Sass worker pool not shutting down fully. This does not happen for rebuilds after the initial. To remedy this situation, The initial build is now wrapped in a try block to ensure that a full shutdown of the Sass worker pool occurs. (cherry picked from commit c3447e3)
1 parent 387472a commit bf4639a

File tree

1 file changed

+16
-10
lines changed
  • packages/angular_devkit/build_angular/src/builders/browser-esbuild

1 file changed

+16
-10
lines changed

packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts

+16-10
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ export async function* buildEsbuildBrowser(
450450
'JIT mode is currently not supported by this experimental builder. AOT mode must be used.',
451451
);
452452

453-
return { success: false };
453+
return;
454454
}
455455

456456
// Inform user of experimental status of builder and options
@@ -461,7 +461,7 @@ export async function* buildEsbuildBrowser(
461461
if (!projectName) {
462462
context.logger.error(`The 'browser-esbuild' builder requires a target to be specified.`);
463463

464-
return { success: false };
464+
return;
465465
}
466466

467467
const normalizedOptions = await normalizeOptions(context, projectName, initialOptions);
@@ -478,18 +478,24 @@ export async function* buildEsbuildBrowser(
478478
assertIsError(e);
479479
context.logger.error('Unable to create output directory: ' + e.message);
480480

481-
return { success: false };
481+
return;
482482
}
483483

484484
// Initial build
485-
let result = await execute(normalizedOptions, context);
486-
yield result.output;
487-
488-
// Finish if watch mode is not enabled
489-
if (!initialOptions.watch) {
490-
shutdownSassWorkerPool();
485+
let result: ExecutionResult;
486+
try {
487+
result = await execute(normalizedOptions, context);
488+
yield result.output;
491489

492-
return;
490+
// Finish if watch mode is not enabled
491+
if (!initialOptions.watch) {
492+
return;
493+
}
494+
} finally {
495+
// Ensure Sass workers are shutdown if not watching
496+
if (!initialOptions.watch) {
497+
shutdownSassWorkerPool();
498+
}
493499
}
494500

495501
context.logger.info('Watch mode enabled. Watching for file changes...');

0 commit comments

Comments
 (0)