GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Flight] Improve error message when it's not a real Error object by sebmarkbage · Pull Request #28327 · react/react

Conversation

@sebmarkbage

@sebmarkbage sebmarkbage commented Feb 14, 2024

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sebmarkbage
sebmarkbage requested a review from gnoff February 14, 2024 18:16
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Feb 14, 2024
@sebmarkbage sebmarkbage changed the title [Flight] Improve error message when it's not a real message object [Flight] Improve error message when it's not a real Error object Feb 14, 2024
@react-sizebot

react-sizebot commented Feb 14, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Comparing: dc31781...fee168e

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 176.83 kB 176.83 kB = 55.11 kB 55.11 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 178.83 kB 178.83 kB = 55.69 kB 55.69 kB
facebook-www/ReactDOM-prod.classic.js = 592.18 kB 592.18 kB = 104.43 kB 104.43 kB
facebook-www/ReactDOM-prod.modern.js = 575.46 kB 575.46 kB = 101.43 kB 101.43 kB
test_utils/ReactAllWarnings.js Deleted 66.26 kB 0.00 kB Deleted 16.32 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-semver/react-server/cjs/react-server-flight.development.js +0.30% 69.74 kB 69.95 kB +0.15% 16.71 kB 16.73 kB
oss-stable/react-server/cjs/react-server-flight.development.js +0.30% 69.74 kB 69.95 kB +0.15% 16.71 kB 16.73 kB
oss-experimental/react-server/cjs/react-server-flight.development.js +0.27% 79.44 kB 79.65 kB +0.12% 18.67 kB 18.70 kB
facebook-www/ReactFlightDOMServer-dev.modern.js +0.25% 87.92 kB 88.14 kB +0.14% 18.75 kB 18.77 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.20% 103.95 kB 104.16 kB +0.12% 24.50 kB 24.53 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.20% 103.95 kB 104.16 kB +0.12% 24.50 kB 24.53 kB
test_utils/ReactAllWarnings.js Deleted 66.26 kB 0.00 kB Deleted 16.32 kB 0.00 kB

Generated by 🚫 dangerJS against fee168e

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sebmarkbage
sebmarkbage force-pushed the flightobjecterror branch from 5a33d8e to 6b66058 Compare February 14, 2024 18:22
gaearon
gaearon approved these changes Feb 14, 2024
View reviewed changes
gnoff
gnoff reviewed Feb 14, 2024
View reviewed changes

@gnoff gnoff left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Should we do the same for encodeErrorForBoundary in Fizz?

Also, seems like in Prod the error boundary isn't catching the error? Don't understand how that could be

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sebmarkbage
sebmarkbage force-pushed the flightobjecterror branch from 6b66058 to 4c64861 Compare February 14, 2024 22:21
@sebmarkbage

sebmarkbage commented Feb 14, 2024

Copy link
Copy Markdown
Contributor Author

Should we do the same for encodeErrorForBoundary in Fizz?

Looks like we look for the .message property there which isn't right, so yea. Probably.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sebmarkbage
Improve error message when it's not a real message object
fee168e
Also deals with symbols.
@sebmarkbage
sebmarkbage force-pushed the flightobjecterror branch from 4c64861 to fee168e Compare February 14, 2024 22:26
@sebmarkbage

sebmarkbage commented Feb 14, 2024

Copy link
Copy Markdown
Contributor Author

It sucks that DevTools doesn't print the .cause of an error. Otherwise we could encode a richer error wrapped in another error.

However this whole DEV-only thing is weird. We probably shouldn't even expose it to programmatic code and only DevTools can actually see the hidden internals just like console.createTask().

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sebmarkbage sebmarkbage mentioned this pull request Feb 14, 2024
Thrown object in RSC to be shown as stringified text not [Object object] in client side (next.js) #28312
Closed
@sebmarkbage
sebmarkbage merged commit a7144f2 into react:main Feb 14, 2024
@sebmarkbage sebmarkbage mentioned this pull request Feb 14, 2024
[Fizz] Align recoverable error serialization in dev mode #28340
Merged
github-actions Bot pushed a commit that referenced this pull request Feb 14, 2024
@sebmarkbage
[Flight] Improve error message when it's not a real Error object (#28327
0fda2b4
)

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.

DiffTrain build for [a7144f2](a7144f2)
sebmarkbage
sebmarkbage commented Feb 15, 2024
View reviewed changes
Comment thread packages/react-server/src/ReactFlightServer.js
} else if (typeof error === 'object' && error !== null) {
message = 'Error: ' + describeObjectForErrorMessage(error);
} else {
message = 'Error: ' + (error: any);

@sebmarkbage sebmarkbage Feb 15, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This prefix actually doesn't really make sense because this prefix already comes as part of the .stack property with the constructor's name.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sebmarkbage added a commit that referenced this pull request Feb 15, 2024
@sebmarkbage
[Fizz] Align recoverable error serialization in dev mode (#28340)
2e470a7
Same as #28327 but for Fizz.

One thing that's weird about this recoverable error is that we don't
send the regular stack for it, just the component stack it seems. This
is missing some potential information and if we move toward integrated
since stacks it would be one thing.
github-actions Bot pushed a commit that referenced this pull request Feb 15, 2024
@sebmarkbage
[Fizz] Align recoverable error serialization in dev mode (#28340)
edb6ecc
Same as #28327 but for Fizz.

One thing that's weird about this recoverable error is that we don't
send the regular stack for it, just the component stack it seems. This
is missing some potential information and if we move toward integrated
since stacks it would be one thing.

DiffTrain build for [2e470a7](2e470a7)
This was referenced Feb 20, 2024
Bump vendored react versions vercel/next.js#62302
Closed
Upgrade vendored react vercel/next.js#62326
Merged
huozhi added a commit to vercel/next.js that referenced this pull request Feb 23, 2024
@huozhi
Upgrade vendored react (#62326)
e5d604f
### React upstream changes

- react/react#28333
- react/react#28334
- react/react#28378
- react/react#28377
- react/react#28376
- react/react#28338
- react/react#28331
- react/react#28336
- react/react#28320
- react/react#28317
- react/react#28375
- react/react#28367
- react/react#28380
- react/react#28368
- react/react#28343
- react/react#28355
- react/react#28374
- react/react#28362
- react/react#28344
- react/react#28339
- react/react#28353
- react/react#28346
- react/react#25790
- react/react#28352
- react/react#28326
- react/react#27688
- react/react#28329
- react/react#28332
- react/react#28340
- react/react#28327
- react/react#28325
- react/react#28324
- react/react#28309
- react/react#28310
- react/react#28307
- react/react#28306
- react/react#28315
- react/react#28318
- react/react#28226
- react/react#28308
- react/react#27563
- react/react#28297
- react/react#28286
- react/react#28284
- react/react#28275
- react/react#28145
- react/react#28301
- react/react#28224
- react/react#28152
- react/react#28296
- react/react#28294
- react/react#28279
- react/react#28273
- react/react#28269
- react/react#28376
- react/react#28338
- react/react#28331
- react/react#28336
- react/react#28320
- react/react#28317
- react/react#28375
- react/react#28367
- react/react#28380
- react/react#28368
- react/react#28343
- react/react#28355
- react/react#28374
- react/react#28362
- react/react#28344
- react/react#28339
- react/react#28353
- react/react#28346
- react/react#25790
- react/react#28352
- react/react#28326
- react/react#27688
- react/react#28329
- react/react#28332
- react/react#28340
- react/react#28327
- react/react#28325
- react/react#28324
- react/react#28309
- react/react#28310
- react/react#28307
- react/react#28306
- react/react#28315
- react/react#28318
- react/react#28226
- react/react#28308
- react/react#27563
- react/react#28297
- react/react#28286
- react/react#28284
- react/react#28275
- react/react#28145
- react/react#28301
- react/react#28224
- react/react#28152
- react/react#28296
- react/react#28294
- react/react#28279
- react/react#28273
- react/react#28269

Closes NEXT-2542


Disable ppr test for strict mode for now, @acdlite will check it and
we'll sync again
@ztanner ztanner mentioned this pull request Mar 19, 2024
(backport) Update React from 60a927d04 to 14898b6a9 vercel/next.js#63442
Closed
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
@sebmarkbage @AndyPengc12
[Flight] Improve error message when it's not a real Error object (rea…
3e128f2
…ct#28327)

Also deals with symbols. Alternative to react#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.
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
@sebmarkbage @AndyPengc12
[Fizz] Align recoverable error serialization in dev mode (react#28340)
425ff2e
Same as react#28327 but for Fizz.

One thing that's weird about this recoverable error is that we don't
send the regular stack for it, just the component stack it seems. This
is missing some potential information and if we move toward integrated
since stacks it would be one thing.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
@sebmarkbage
[Flight] Improve error message when it's not a real Error object (#28327
cf544ed
)

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.

DiffTrain build for commit a7144f2.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
@sebmarkbage
[Fizz] Align recoverable error serialization in dev mode (#28340)
fb9b7a4
Same as #28327 but for Fizz.

One thing that's weird about this recoverable error is that we don't
send the regular stack for it, just the component stack it seems. This
is missing some potential information and if we move toward integrated
since stacks it would be one thing.

DiffTrain build for commit 2e470a7.
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@sebmarkbage
[Flight] Improve error message when it's not a real Error object (rea…
6bc7c64
…ct#28327)

Also deals with symbols. Alternative to react#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.
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@sebmarkbage
[Fizz] Align recoverable error serialization in dev mode (react#28340)
aa7f8f8
Same as react#28327 but for Fizz.

One thing that's weird about this recoverable error is that we don't
send the regular stack for it, just the component stack it seems. This
is missing some potential information and if we move toward integrated
since stacks it would be one thing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gnoff gnoff gnoff left review comments
@gaearon gaearon gaearon approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@sebmarkbage @react-sizebot @gaearon @gnoff @facebook-github-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.