Fix & Test for WorkerPool Initialization Race#598
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 10b4ffb61b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (originalRequestAnimationFrame != null) { | ||
| globalThis.requestAnimationFrame = originalRequestAnimationFrame; | ||
| } |
There was a problem hiding this comment.
Reset RAF globals when originals are undefined
This teardown only restores requestAnimationFrame when an original function existed, so in Bun/Node test environments where it starts as undefined, the shim remains installed after this file finishes. That leaks fake RAF behavior into later test files and can cause order-dependent failures. The same pattern is used for cancelAnimationFrame, so both globals should be explicitly reset (or deleted) in the else path.
Useful? React with 👍 / 👎.
Created a regression test for the race WorkerPool initialization/termination/initialization case. Then created a fix that better handles the various async states that can occur.