feat: add workerGracefulExitTimeout config option#15984
feat: add workerGracefulExitTimeout config option#15984jcwatson11 wants to merge 2 commits intojestjs:mainfrom
Conversation
Add a configurable timeout for how long worker processes are given to exit gracefully before being force-killed. The previous hardcoded 500ms delay caused false-positive "failed to exit gracefully" warnings when workers naturally take close to 500ms to shut down. The new option defaults to 500 (preserving existing behavior) and can be set via jest.config.js or --workerGracefulExitTimeout CLI flag.
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
babel-jest
babel-plugin-jest-hoist
babel-preset-jest
create-jest
@jest/diff-sequences
expect
@jest/expect-utils
jest
jest-changed-files
jest-circus
jest-cli
jest-config
@jest/console
@jest/core
@jest/create-cache-key-function
jest-diff
jest-docblock
jest-each
@jest/environment
jest-environment-jsdom
@jest/environment-jsdom-abstract
jest-environment-node
@jest/expect
@jest/fake-timers
@jest/get-type
@jest/globals
jest-haste-map
jest-jasmine2
jest-leak-detector
jest-matcher-utils
jest-message-util
jest-mock
@jest/pattern
jest-phabricator
jest-regex-util
@jest/reporters
jest-resolve
jest-resolve-dependencies
jest-runner
jest-runtime
@jest/schemas
jest-snapshot
@jest/snapshot-utils
@jest/source-map
@jest/test-result
@jest/test-sequencer
@jest/transform
@jest/types
jest-util
jest-validate
jest-watcher
jest-worker
pretty-format
commit: |
- Fix Prettier violation in jest-runner/src/index.ts - Update showConfig e2e snapshot with new config option - Revert normalize.test.ts snapshots to match CI color output
|
The remaining two failing checks (Windows shard 1/4 on Node v24 and Node LTS jest-jasmine2) are unrelated to this PR's changes. They fail on a snapshot in The issue is that the Happy to include a fix in this PR (normalizing that portion of the error message in the test), but also totally understand if you'd prefer to address it separately. Just let me know! |
Summary
workerGracefulExitTimeoutconfig option (and CLI flag) to control how long worker processes are given to exit gracefully before being force-killedjest-worker,jest-config,jest-runner,jest-cli,jest-schemas, andjest-typesMotivation
jest-worker hardcodes
FORCE_EXIT_DELAY = 500ms — the time workers get after all tests complete before being SIGTERM'd. Workers that don't exit in time trigger a "A worker process has failed to exit gracefully" warning. In practice, workers naturally exit in 130–500ms, so the fixed 500ms threshold causes intermittent false-positive warnings under normal load.Making this configurable lets users tune the threshold for their environment without patching jest-worker.
Relates to #11354
Relates to #15468
Relates to #13139
Test plan
BaseWorkerPool.test.tsverifying custom timeout is respected and default (500ms) is preservedyarn buildpasses (type-check clean)jest-worker(152),jest-config(266),jest-runner(15),jest-cli(6)