fix(jest-haste-map): Fix clobbering/errors when multiple configs use different haste impls#15522
Merged
cpojer merged 2 commits intoMay 22, 2025
Merged
Conversation
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
4 tasks
cpojer
approved these changes
May 22, 2025
Member
cpojer
left a comment
There was a problem hiding this comment.
This looks like a piece of code that existed because it wasn't supposed to happen at FB, and now it is happening. Heh.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
jest-haste-map'sworkercurrently enforces (or tries to enforce) that all of its workloads use the samehasteImplModulePath.This is problematic when multiple configurations, whose
hasteImplModulePathmay differ, share ajest-haste-mapworker - in particular:--runInBandor--maxWorkers=1Math.floor(maxWorkers / configs.length) == 1,jest-file-mapprocessing is in-band.In these cases, where
worker.jsis loaded as an ordinary module by the host process, there are two bugs:hasteImplwill be set by the first config and incorrectly silently reused by the second config (because we don't trigger the error condition, but do reusehasteImpl), potentially causing spurious collision errors.The point of this check seems to be to allow caching of
hasteImplon the assumption that a given worker only sees one config. That caching doesn't really save any time though, becauserequirecalls are already backed by Node's own module cache.So we simplify the worker, fix the bugs, and incur no observable performance penalty by just removing the check.
Test plan
Made this modification locally to Jest at Meta, where we currently have 5 projects including 2 different haste impls. We observed the bug on 10 core machines where
jest-haste-mapinstances were allocatedMath.floor( (10-1) / 5 ) == 1workers, and this change fixes it.