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
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker action: global presubmit The PR is in need of a google3 global presubmit and removed action: global presubmit The PR is in need of a google3 global presubmit labels Jul 22, 2026
@clydin clydin added target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: minor This PR is targeted for the next minor 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()

2 participants