Skip to content

[heft-jest-plugin] Supervise sequential Jest worker lifecycles - #6207

Open
Yashwanth Reddy Verupaka (yashwanth195) wants to merge 3 commits into
microsoft:mainfrom
yashwanth195:user/yverupaka/jest-worker-lifecycle-pr
Open

Yashwanth Reddy Verupaka (yashwanth195) wants to merge 3 commits into
microsoft:mainfrom
yashwanth195:user/yverupaka/jest-worker-lifecycle-pr

Conversation

@yashwanth195

@yashwanth195 Yashwanth Reddy Verupaka (yashwanth195) commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Jest can restart a worker between tasks when its idle-memory limit is exceeded. Sending the next task before the replacement is ready can turn an expected recycle into a task failure. Unexpected worker exits must also be reported rather than silently retrying in-flight work.

This PR adds JestManagedWorkerQueue to supervise a single sequential worker configured with zero retries. It observes Jest's public task callbacks and lifecycle events, lets the caller wait for replacement readiness before dispatching another task, and retains unexpected exit or replacement failures while stopping the owned workers. It also recognizes expected recycling after the final task so the caller can handle shutdown without waiting for a replacement that has no work to perform.

This is a standalone foundation for future managed-runner integration. It does not enable managed sharding or change ordinary Jest execution.

Details

  • Observe public Jest queue callbacks and worker lifecycle handles.
  • Wait for recycled workers to become ready between tasks, retain failures, and clean up owned handles on unexpected termination or replacement.
  • Handle final-task recycling separately from unexpected failure during shutdown.
  • Add jest-worker ~30.3.0 and update both subspaces' dependency metadata, including the injected snapshot and generated hashes required by CI.

How it was tested

On Windows with Node 24.22.1 and Rush 5.182.0:

  • node common\scripts\install-run-rush.js test --only @rushstack/heft-jest-plugin --parallelism 4 — passed build/lint and all 38 tests, including 16 real process/thread lifecycle cases.
  • node common\scripts\install-run-rush.js install --subspace build-tests-subspace — passed frozen installation after refreshing injected dependency metadata.

Coverage includes worker reuse/recycling, replacement readiness, unexpected exits without replay, final-task shutdown, and failure cleanup. Full managed-runner integration is deferred.

Impacted documentation

Updated the package README and class-level caller contract. No website or schema changes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

1 participant