Skip to content

fix(@angular/build): add bounded timeout to vitest executor disposal#33620

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix/vitest-close-timeout
Open

fix(@angular/build): add bounded timeout to vitest executor disposal#33620
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix/vitest-close-timeout

Conversation

@clydin

@clydin clydin commented Jul 22, 2026

Copy link
Copy Markdown
Member

When disposing the VitestExecutor in non-watch runs, vitest.close() can hang if a Vitest worker pool process or thread fails to terminate cleanly. Calling process.exit() in a builder runner is undesirable as it forcibly kills the host Node.js process and aborts any downstream Architect tasks or reporters.

This change wraps this.vitest.close() in a Promise.race with an unref'd setTimeout. If close() stalls beyond 10 seconds, a warning is logged and disposal finishes cleanly, allowing host process execution and downstream logic to proceed.

Fixes #32832

@clydin clydin added the target: patch This PR is targeted for the next patch release label Jul 22, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a 10-second timeout when closing the Vitest instance during the disposal of VitestExecutor to prevent hanging processes. The review feedback correctly identifies a potential unhandled promise rejection issue: aborting the AbortController in the finally block will cause the setTimeout promise to reject after Promise.race has already settled. A code suggestion is provided to catch and suppress this AbortError safely.

When disposing the VitestExecutor in non-watch runs, `vitest.close()` can hang if a Vitest worker pool process or thread fails to terminate cleanly. Calling `process.exit()` in a builder runner is undesirable as it forcibly kills the host Node.js process and aborts any downstream Architect tasks or reporters.

This change wraps `this.vitest.close()` in a `Promise.race` with an unref'd `setTimeout`. If `close()` stalls beyond 10 seconds, a warning is logged and disposal finishes cleanly, allowing host process execution and downstream logic to proceed.

Fixes angular#32832
@clydin
clydin force-pushed the fix/vitest-close-timeout branch from f0b9b35 to ab65d8f Compare July 22, 2026 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@angular/build:unit-test vitest executor hangs indefinitely — uses close() instead of exit()

1 participant