fix: set non-zero exit code when teardown throws during close#10794
Merged
sheremet-va merged 2 commits intoJul 21, 2026
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
zakcutner
force-pushed
the
fix/close-teardown-exit-code
branch
from
July 20, 2026 10:00
0cfa5c2 to
0b596f2
Compare
zakcutner
force-pushed
the
fix/close-teardown-exit-code
branch
from
July 20, 2026 10:10
0b596f2 to
4876a68
Compare
AriPerkkio
approved these changes
Jul 21, 2026
AriPerkkio
left a comment
Member
There was a problem hiding this comment.
Reporting project._teardownGlobalSetup() errors as unhandled errors makes sense to me. I'm not fully sure if pool closing and project cleanups should be treated too. Though why not 🤔
sheremet-va
approved these changes
Jul 21, 2026
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.
Description
Errors thrown while closing Vitest, most notably a failing
globalSetupteardown, were logged but never affected the exit code. As a resultvitest runexited 0 even though cleanup failed.vitest.close()catches teardown errors since #9573, so that the rest of the shutdown still runs, and logs them vialogger.error('error during close', ...). However, nothing set a non-zero exit code afterwards, so any cleanup failure in aglobalSetupteardown was silently swallowed.This change routes the collected errors, meaning teardown errors plus any rejected close promises, through the existing
_checkUnhandledErrors. That is the same mechanism used for unhandled test errors. It setsprocess.exitCodeto 1 and honoursdangerouslyIgnoreUnhandledErrors.Reproduction
A
globalSetupwhose teardown throws, with otherwise passing tests:Before this change,
vitest runprints the error but exits 0. After, it exits 1.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.