fix(jest-util): stop globalsCleanup 'soft' mode from infinite-recursing on data-property writes (#16044)#16210
Open
LeSingh1 wants to merge 1 commit into
Conversation
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
…ng on data-property writes (jestjs#16044) In soft deletion mode, deleteProperty wraps every visited property with a setter that emits a deprecation warning and forwards to the original setter. For data descriptors (the common case), the original setter defaulted to (value => Reflect.set(obj, key, value)) -- which routed the write back through the exact same wrapping setter we had just installed, producing RangeError: Maximum call stack size exceeded on the first write after soft delete. Keep the data-property value in a closure-scoped slot instead. Accessor descriptors that already carry their own setter keep using it because descriptor.set(value) does not re-enter the wrapping setter. Adds regression coverage in packages/jest-util/src/__tests__/garbage-collection-utils.test.ts that fails on main with the recursion error and passes on this branch. Fixes jestjs#16044.
9ede299 to
485e4c9
Compare
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: |
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.
Fixes #16044.
Bug
In soft deletion mode,
deletePropertyinjest-util/src/garbage-collection-utils.tswraps every visited property with a setter that emits a deprecation warning and then forwards to the original setter. For data descriptors (the common case), the original setter defaulted to:That
Reflect.set(obj, key, value)routes the write back through the same wrapping setter we just installed onobj[key], producingRangeError: Maximum call stack size exceededon the first write to any soft-deleted data property.Reproducer from the issue:
Fix
Keep the data-property value in a closure-scoped slot instead of routing back through
Reflect.set. Accessor descriptors that already carry their own setter keep using it because callingdescriptor.set(value)directly does not re-enter the wrapping setter.Verification
Added regression coverage in
packages/jest-util/src/__tests__/garbage-collection-utils.test.tscovering:Local A/B run:
The tests construct prototype-less objects (
Object.create(null)) so they bypass thePROTECT_SYMBOLvalue jest-circus installs on the global scope, which would otherwise causedeletePropertiesto treat every own key as protected and skip the wrapping path entirely.CHANGELOG
Added an entry under
## main->### Fixesreferencing this PR.