Skip to content

fix max call stack exceeded when setting token values from change handler#6499

Merged
nicholasrice merged 9 commits intomasterfrom
users/nirice/fix-max-call-stack-exceeded
Nov 9, 2022
Merged

fix max call stack exceeded when setting token values from change handler#6499
nicholasrice merged 9 commits intomasterfrom
users/nirice/fix-max-call-stack-exceeded

Conversation

@nicholasrice
Copy link
Copy Markdown
Contributor

Pull Request

📖 Description

This PR fixes an bug where setting a token value from a subscriber causes a RangeError, max call stack exceeded.

🎫 Issues

Closes #6464

👩‍💻 Reviewer Notes

The core of the issue is that setting a token from a subscriber would force DesignToken to go through the notification code-path again. Because the subscribers had not been cleared at that point, it would enter an endless loop and throw. To avoid this, the notification stack is cleared before any of the notifiers are called. This avoids the recursive loop and the scenario no longer throws.

📑 Test Plan

✅ Checklist

General

  • I have included a change request file using $ yarn change
  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Component-specific

⏭ Next Steps

@nicholasrice nicholasrice force-pushed the users/nirice/fix-max-call-stack-exceeded branch from 724ccfe to 3ae2393 Compare November 4, 2022 04:40
@EisenbergEffect
Copy link
Copy Markdown
Contributor

@nicholasrice I think this one is ready whenever you are.

@nicholasrice nicholasrice merged commit e4a2bfc into master Nov 9, 2022
@nicholasrice nicholasrice deleted the users/nirice/fix-max-call-stack-exceeded branch November 9, 2022 14:43
janechu pushed a commit that referenced this pull request Jun 10, 2024
…dler (#6499)

* fixing issue and adding regression tests

* Change files

Co-authored-by: nicholasrice <nicholasrice@users.noreply.github.com>
Co-authored-by: Chris Holt <chhol@microsoft.com>
Co-authored-by: Rob Eisenberg <EisenbergEffect@users.noreply.github.com>
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.

fix: DesignToken max callstack exceded when setting a token from a token subscriber

3 participants