dillon1000/react
Commit
Browse files Throw special error if rejected Promises are incorrectly instrumented (#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.
Changed paths5 files
First-parent comparisonpackages/react-reconciler/src/ReactFiberThenable.js ModifiedM packages/react-reconciler/src/__tests__/ReactUse-test.js ModifiedM packages/react-server/src/ReactFizzThenable.js ModifiedM packages/react-server/src/ReactFlightThenable.js ModifiedM scripts/error-codes/codes.json ModifiedPatch
Files changed
Rendering syntax-highlighted changes…