Throw special error if rejected Promises are incorrectly instrumented#36328
Merged
Conversation
ab70052 to
8fc1b9e
Compare
4c13990 to
2ba964a
Compare
2ba964a to
0856999
Compare
unstubbable
approved these changes
May 27, 2026
github-actions Bot
pushed a commit
that referenced
this pull request
May 27, 2026
…#36328) When a rejected `Promise` is instrumented in userspace while setting the rejection reason in the wrong field (e.g. `error` instead of `reason`), React will throw undefined (because `usable.reason` doesn't exist). This makes it incredibly hard to find the actual rejection reason. React is now throwing a generic error if we couldn't find the rejection reason. That will produce a callstack pointing into the problematic Promise from where you can hopefully extract the real rejection reason (alongside fixing the bad instrumentation). We're doing this in prod since this is unlikely to surface in dev. We're only doing runtime type-checking for the rejected case. That should be hit rarely and therefore hopefully have negligible runtime impact. DiffTrain build for [c0cd4d5](c0cd4d5)
github-actions Bot
pushed a commit
that referenced
this pull request
May 27, 2026
…#36328) When a rejected `Promise` is instrumented in userspace while setting the rejection reason in the wrong field (e.g. `error` instead of `reason`), React will throw undefined (because `usable.reason` doesn't exist). This makes it incredibly hard to find the actual rejection reason. React is now throwing a generic error if we couldn't find the rejection reason. That will produce a callstack pointing into the problematic Promise from where you can hopefully extract the real rejection reason (alongside fixing the bad instrumentation). We're doing this in prod since this is unlikely to surface in dev. We're only doing runtime type-checking for the rejected case. That should be hit rarely and therefore hopefully have negligible runtime impact. DiffTrain build for [c0cd4d5](c0cd4d5)
lubieowoce
pushed a commit
to vercel/next.js
that referenced
this pull request
May 27, 2026
[diff facebook/react@75b0945b...c0cd4d5d](facebook/react@75b0945...c0cd4d5) <details> <summary>React upstream changes</summary> - facebook/react#36328 - facebook/react#36542 - facebook/react#36544 </details> --------- Co-authored-by: next-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.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.
When a rejected
Promiseis instrumented in userspace while setting the rejection reason in the wrong field (e.g.errorinstead ofreason), React will throw undefined (becauseusable.reasondoesn't exist). This makes it incredibly hard to find the actual rejection reason.React is now throwing a generic error if we couldn't find the rejection reason. That will produce a callstack pointing into the problematic Promise from where you can hopefully extract the real rejection reason (alongside fixing the bad instrumentation).
We're doing this in prod since this is unlikely to surface in dev. We're only doing runtime type-checking for the rejected case. That should be hit rarely and therefore hopefully have negligible runtime impact.