fix(@angular/build): prevent esbuild service child process leakage#33267
Open
clydin wants to merge 1 commit into
Open
fix(@angular/build): prevent esbuild service child process leakage#33267clydin wants to merge 1 commit into
clydin wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request wraps the watcher setup and initial build result emission in a try-finally block to ensure that the build result is disposed of when not in watch mode. It also simplifies the bundler context by always creating and rebuilding an esbuild context instead of branching for non-incremental builds. A review comment identifies a potential resource leak if an error occurs during the initial emit or watcher setup when watch mode is enabled, as the current finally block only disposes of the result if watch mode is disabled. A suggestion is provided to track whether the generator successfully transitions to the watch loop and clean up resources accordingly.
Use scoped esbuild.context() for single builds to guarantee accurate tracking and clean disposal of all internal esbuild service child processes. Additionally, wrap runEsBuildBuildAction in a try/finally block leveraging a state tracking flag to deterministically trigger context disposal for all single builds and watch initialization failure paths. This leakage primarily impacts programmatic usage and custom Architect decorators, where the hosting Node.js process remains alive after build completion. Fixes angular#33201
81d0675 to
2d9b166
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use scoped esbuild.context() for single builds to guarantee accurate tracking and clean disposal of all internal esbuild service child processes. Additionally, wrap runEsBuildBuildAction in a try/finally block to deterministically trigger context disposal when a single build finishes or encounters an error.
This leakage primarily impacts programmatic usage and custom Architect decorators, where the hosting Node.js process remains alive after build completion.
Fixes #33201