{{ message }}
Repository navigation
test(muya): stop the deepClone spec from overflowing the stack itself - #5505
Merged
Merged
Conversation
…#5504) `copies a 600-level nested list without exhausting the stack` failed intermittently on CI with RangeError — twice on unrelated PRs (#5496, #5502), passing on re-run with no code change. The recursion was in the test, not in `deepClone`. Measured ceilings for the fixture shape this spec builds: deepClone(nested(d)) alone 100000 levels, never threw the test body, verbatim ok <= 900, RangeError @ 1000 expect(a).not.toBe(b) ok <= 900, RangeError @ 1000 structuredClone (the #4747 ok <= 600, throws @ 700 control) `expect(copy).not.toBe(state)` hands the whole 600-level structure (~2400 nested containers) to Vitest, which recurses once per level inspecting the argument. That left a margin of 600 -> ~900, and the ceiling moves with the Node build and the worker thread's stack size, so CI landed on the wrong side of it about half the time. Compare identity outside the matcher so only booleans reach `expect`. With the fixture raised to 10000 levels the spec now passes; restoring just those two lines at the same depth reproduces the CI RangeError exactly. The spec's own comment already warned that "a recursive equality check" would overflow this input — `expect(deepObject)` is one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

Closes #5504
Summary
copies a 600-level nested list without exhausting the stack (#4747)fails intermittently on CI withRangeError: Maximum call stack size exceeded— it has now blocked two unrelated PRs (#5496, #5502) and passed on re-run with no code change.The recursion is in the test, not in
deepClone.Measured ceilings for the fixture shape this spec builds
deepClone(nested(d))aloneexpect(a).not.toBe(b)onnested(d)structuredClone— the #4747 controlJSON.stringify— controlRoot cause
These hand the whole 600-level structure (~2400 nested containers) to Vitest, which recurses once per level while inspecting the argument. The test's margin was 600 → ~900, under 1.5×, and the ceiling moves with the Node build, the worker thread's stack size and how deep the caller's stack already is — so CI lands on the wrong side of it about half the time.
The
deepClonerewrite from #5259 is fine: iterative, 100 000 levels with no trouble. The spec's own comment already warned that "a recursive equality check" would overflow this input;expect(deepObject)is one.Fix
Compare identity outside the matcher so only booleans reach
expect.Verification — controlled, both directions
With the fixture temporarily raised to 10 000 levels:
expect(deep)lines restored, same depthThat isolates the cause to those two lines. Committed state keeps the fixture at 600; muya unit suite 2003 passed (256 files), ESLint clean.
🤖 Generated with Claude Code