dillon1000/react
Commit
Browse files [Flight] Improve error message when it's not a real Error object (#28327)
Also deals with symbols. Alternative to #28312. We currently always normalize rejections or thrown values into `Error` objects. Partly because in prod it'll be an error object and you shouldn't fork behavior on knowing the value outside a digest. We might want to even make the message always opaque to avoid being tempted and then discover in prod that it doesn't work. However, we do include the message in DEV. If this is a non-Error object we don't know what the properties mean. Ofc, we don't want to include too much information in the rendered string, so we use the general `describeObjectForErrorMessage` helper. Unfortunately it's pretty conservative about emitting values so it's likely to exclude any embedded string atm. Could potentially expand it a bit. We could in theory try to serialize as much as possible and re-throw the actual object to allow for inspection to be expanded inside devtools which is what I plan on for consoles, but since we're normalizing to an Error this is in conflict with that approach.
Changed paths2 files
First-parent comparisonpackages/react-client/src/__tests__/ReactFlight-test.js ModifiedM packages/react-server/src/ReactFlightServer.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…