Skip to content

Commit c3447e3

Browse files
clydinangular-robot[bot]
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.
1 parent 7b5b8f8 commit c3447e3

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

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

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

472-
return { success: false };
472+
return;
473473
}
474474

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

483-
return { success: false };
483+
return;
484484
}
485485

486486
const normalizedOptions = await normalizeOptions(context, projectName, initialOptions);
@@ -497,18 +497,24 @@ export async function* buildEsbuildBrowser(
497497
assertIsError(e);
498498
context.logger.error('Unable to create output directory: ' + e.message);
499499

500-
return { success: false };
500+
return;
501501
}
502502

503503
// Initial build
504-
let result = await execute(normalizedOptions, context);
505-
yield result.output;
506-
507-
// Finish if watch mode is not enabled
508-
if (!initialOptions.watch) {
509-
shutdownSassWorkerPool();
504+
let result: ExecutionResult;
505+
try {
506+
result = await execute(normalizedOptions, context);
507+
yield result.output;
510508

511-
return;
509+
// Finish if watch mode is not enabled
510+
if (!initialOptions.watch) {
511+
return;
512+
}
513+
} finally {
514+
// Ensure Sass workers are shutdown if not watching
515+
if (!initialOptions.watch) {
516+
shutdownSassWorkerPool();
517+
}
512518
}
513519

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

0 commit comments

Comments
 (0)