fix: close REPL servers after each test to prevent Jest worker from hanging#1847
Merged
pmcelhaney merged 2 commits intomainfrom Apr 13, 2026
Merged
fix: close REPL servers after each test to prevent Jest worker from hanging#1847pmcelhaney merged 2 commits intomainfrom
pmcelhaney merged 2 commits intomainfrom
Conversation
Copilot
AI
changed the title
[WIP] Fix worker process to exit gracefully in Jest
fix: close REPL servers after each test to prevent Jest worker from hanging
Apr 13, 2026
pmcelhaney
approved these changes
Apr 13, 2026
pmcelhaney
approved these changes
Apr 13, 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.
Summary
Each test in
test/repl/repl.test.tscalledstartRepl()→repl.start(), creating a Node.jsREPLServerthat holdsprocess.stdinopen. Nothing ever closed them, so Jest workers couldn't exit, producing the "worker process has failed to exit gracefully" error.Changes:
test/repl/repl.test.ts: track everyREPLServercreated bycreateHarness()in a module-level array; drain and close all of them inafterEachOriginal Prompt
Jest is reporting open handles. Fix the issue so Jest can exit gracefully.
Manual acceptance tests
yarn testcompletes without "A worker process has failed to exit gracefully" in the outputyarn node --experimental-vm-modules ./node_modules/jest-cli/bin/jest --testPathPatterns=repl.test --coverageThreshold='{}') finishes in under 5 seconds instead of hangingTasks
repl.test.tshangs indefinitely when run in isolation (timed out after 20 s)openServerstracking array andafterEachcleanup totest/repl/repl.test.tscreateHarnessto register each new server for cleanup