test: stop integration runs failing on teardown console race#6702
Draft
macko911 wants to merge 1 commit into
Draft
test: stop integration runs failing on teardown console race#6702macko911 wants to merge 1 commit into
macko911 wants to merge 1 commit into
Conversation
Vitest 4 intercepts worker console output and ships it to the main process over an RPC. Handlers in these tests do fire-and-forget logging that outlives the request (e.g. the proxy's enrichOperation in a finally block), so a stray log can fire as the worker tears down and race the closing RPC, failing the whole run with "EnvironmentTeardownError: Closing rpc while onUserConsoleLog was pending" even when every test passed. Set disableConsoleIntercept so worker console writes go straight to stdout/stderr, removing the RPC entirely. No test relies on console interception.
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.
Problem
Integration CI can fail even when every test passes. Under Vitest 4, worker console output is intercepted and shipped to the main process over an RPC. Handlers in these tests do fire-and-forget logging that outlives the request (e.g. the proxy's
enrichOperationin afinallyblock), so a stray log can fire as the worker tears down and race the closing RPC. The run then fails withEnvironmentTeardownError: Closing rpc while "onUserConsoleLog" was pending, attributed toallProxy.integration.test.ts— the most recent occurrence passed all 317 tests but still exited 1.Solution
disableConsoleIntercept: trueinvite.integration.config.tsso worker console writes go straight to stdout/stderr, removing the RPC the stray log was racing.This is a class of flake — any integration test whose handler logs asynchronously can trip it, not just the proxy suite. No test relies on Vitest's console interception.
Trade-offs
Pros
onUserConsoleLogteardown-race flake class, not just the proxy case.dangerouslyIgnoreUnhandledErrorswould swallow real unhandled errors, and fixing it at the source would mean blocking HTTP responses on fire-and-forget logging.Cons
stdout | file > testprefix, so free-floating logs are no longer attributable to a specific test in CI output.maxWorkers: 1+fileParallelism: false, so logs stay serial).Testing
allProxy.integration.test.tsagainst the fix: 7/7 pass, noErrorsline and noEnvironmentTeardownError.