-
Notifications
You must be signed in to change notification settings - Fork 11.9k
fix(@angular/build): Proper shutdown of esbuild workers #33202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| import { BuilderContext } from '@angular-devkit/architect'; | ||
| import { existsSync } from 'node:fs'; | ||
| import path from 'node:path'; | ||
| import { shutdownEsbuild } from '../../tools/esbuild/bundler-context'; | ||
| import { ExecutionResult, RebuildState } from '../../tools/esbuild/bundler-execution-result'; | ||
| import { BuildOutputFile, BuildOutputFileType } from '../../tools/esbuild/bundler-files'; | ||
| import { shutdownSassWorkerPool } from '../../tools/esbuild/stylesheets/sass-language'; | ||
|
|
@@ -89,9 +90,10 @@ export async function* runEsBuildBuildAction( | |
| // Log all diagnostic (error/warning/logs) messages | ||
| await logMessages(logger, result, colors, jsonLogs); | ||
| } finally { | ||
| // Ensure Sass workers are shutdown if not watching | ||
| // Ensure workers are shutdown if not watching | ||
| if (!watch) { | ||
| shutdownSassWorkerPool(); | ||
| await shutdownEsbuild(); | ||
| } | ||
|
Comment on lines
94
to
97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could fix this but it feels out-of-scope, I deliberately chose a minimum fix. This would require a bigger refactor |
||
| } | ||
|
|
||
|
|
@@ -219,6 +221,7 @@ export async function* runEsBuildBuildAction( | |
| await Promise.allSettled([watcher.close(), result.dispose()]); | ||
|
|
||
| shutdownSassWorkerPool(); | ||
| await shutdownEsbuild(); | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the non-watch path,
result.dispose()is not called. WhileshutdownEsbuild()stops the shared esbuild process, explicitly disposing the result is consistent with the watch-mode cleanup (line 221) and ensures that any incremental build resources (like the esbuild context) are properly released. Usingresult?.dispose()is safer in case the build action itself failed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While fair, this will throw an "used before initialized" error since technically, result isn't initialized yet