Skip to content

fix: preserve recursive call result order - #2768

Open
ryanchou1994 wants to merge 1 commit into
sinonjs:mainfrom
ryanchou1994:fix/recursive-call-results
Open

ryanchou1994 wants to merge 1 commit into
sinonjs:mainfrom
ryanchou1994:fix/recursive-call-results

Conversation

@ryanchou1994

Copy link
Copy Markdown

Purpose (TL;DR) - mandatory

Keep return values, exceptions, and call stacks associated with the correct invocation when a spy or fake calls itself recursively. Save each proxy's call index before invoking the wrapped function, including the separate indices of its withArgs matches.

Fixes #1849.

How to verify - mandatory

  1. Check out this branch and run npm ci.
  2. Run npm run test-node -- --grep "recursive calls" for the seven regression cases.
  3. Run npm test, npm run lint, npm run prettier:check, and npm run build.

Verified on macOS with Node 26 and Linux with Node 24: 1,563 Node tests, 1,556 Chrome tests, and the WebWorker test pass. The existing 12 Node / 13 browser pending tests remain pending. Lint, formatting, build, package contract checks, and coverage thresholds also pass.

Checklist for author

  • npm run lint passes
  • References to standard library functions are cached.

Copilot AI lite review requested due to automatic review settings September 9, 2026 18:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

None yet

Development

Successfully merging this pull request may close these issues.

returnValue of calls is out of order when spying on recursive functions

2 participants