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 — Fix error handling when name is a Symbol by jon-ressio · Pull Request #28354 · react/react

Conversation

@jon-ressio

@jon-ressio jon-ressio commented Feb 16, 2024

Copy link
Copy Markdown

Summary

Error discovered in a next.js application. Normal warning about complex types being passed to client components from a server component, but in this case the code that tries to render a warning/error message actually causes a different error/exception that masks the original error.
I initially filed the issue against next.js ( vercel/next.js#61966 ) with a repro example ( https://github.com/jon-ressio/vercel-prop-warn-error ).

I now think this is just from 1 case of String() not being called on name, so trying to concatenate a string and a symbol. I fixed the two places I saw the same pattern.

How did you test this change?

I have not tested it yet. I can figure out how to yarn link and build next against my build of react that includes the fix, but it would take me a bit. This feels like a pretty safe change, but if you'd like me to validate I can definitely do that, just let me know.

Sorry, something went wrong.

Uh oh!

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

All reactions
@jonstelly
Fix error handling when name is a Symbol
7443411
@facebook-github-bot facebook-github-bot added the CLA Signed label Feb 16, 2024
@sebmarkbage

sebmarkbage commented Feb 16, 2024

Copy link
Copy Markdown
Contributor

Thanks for reporting. I don't think this exactly the right fix. Because a client reference can never be extracted from a symbol export since it can't be referenced. Basically the proxy can't support symbols and should probably error in that case.

In particular the symbol trying to be extracted here is the Symbol.toStringTag symbol which maybe we should special case as being allowed in the proxy.

We can also special case detecting that this is a ClientReference when printing the error.

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 16, 2024
Encode better error messages when part of the context is a client reference #28355
Merged
@sebmarkbage

sebmarkbage commented Feb 16, 2024

Copy link
Copy Markdown
Contributor

Alternative fix in #28355.

All reactions

Sorry, something went wrong.

Uh oh!

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

@sebmarkbage sebmarkbage closed this Feb 16, 2024
@jon-ressio

jon-ressio commented Feb 16, 2024

Copy link
Copy Markdown
Author

Excellent, really appreciate the crazy-fast turnaround to get it fixed the right way. See your tests, look good and should cover my case.

Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

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

@sebmarkbage

sebmarkbage commented Feb 16, 2024

Copy link
Copy Markdown
Contributor

You got lucky I was working on improving error messages anyway. 😅

All reactions

Sorry, something went wrong.

Uh oh!

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

sebmarkbage added a commit that referenced this pull request Feb 19, 2024
@sebmarkbage
Encode better error messages when part of the context is a client ref…
c323f82
…erence (#28355)

Alternative to #28354.

If a client reference is one of the props being describes as part of
another error, we call toString on it, which errors.

We should error explicitly when a Symbol prop is extracted.

However, pragmatically I added the toString symbol tag even though we
don't know what the real tostring will be but we also lie about the
typeof.

We can however in addition to this give it a different description
because describing this property as an object isn't quite right.

We probably could extract the export name but that's kind of renderer
specific and I just added this shared module to Fizz which doesn't have
that which is unfortunate an consequence.

For default exports we don't have a good name of what the alias was in
the receiver. Could maybe call it "default" but for now I just call it
"client".
@jon-ressio
jon-ressio deleted the fix/symbol-name-handling branch April 12, 2024 20:55
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
@sebmarkbage @AndyPengc12
Encode better error messages when part of the context is a client ref…
95f4929
…erence (react#28355)

Alternative to react#28354.

If a client reference is one of the props being describes as part of
another error, we call toString on it, which errors.

We should error explicitly when a Symbol prop is extracted.

However, pragmatically I added the toString symbol tag even though we
don't know what the real tostring will be but we also lie about the
typeof.

We can however in addition to this give it a different description
because describing this property as an object isn't quite right.

We probably could extract the export name but that's kind of renderer
specific and I just added this shared module to Fizz which doesn't have
that which is unfortunate an consequence.

For default exports we don't have a good name of what the alias was in
the receiver. Could maybe call it "default" but for now I just call it
"client".
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
@sebmarkbage
Encode better error messages when part of the context is a client ref…
9afcb68
…erence (#28355)

Alternative to #28354.

If a client reference is one of the props being describes as part of
another error, we call toString on it, which errors.

We should error explicitly when a Symbol prop is extracted.

However, pragmatically I added the toString symbol tag even though we
don't know what the real tostring will be but we also lie about the
typeof.

We can however in addition to this give it a different description
because describing this property as an object isn't quite right.

We probably could extract the export name but that's kind of renderer
specific and I just added this shared module to Fizz which doesn't have
that which is unfortunate an consequence.

For default exports we don't have a good name of what the alias was in
the receiver. Could maybe call it "default" but for now I just call it
"client".

DiffTrain build for commit c323f82.
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@sebmarkbage
Encode better error messages when part of the context is a client ref…
ceeb354
…erence (react#28355)

Alternative to react#28354.

If a client reference is one of the props being describes as part of
another error, we call toString on it, which errors.

We should error explicitly when a Symbol prop is extracted.

However, pragmatically I added the toString symbol tag even though we
don't know what the real tostring will be but we also lie about the
typeof.

We can however in addition to this give it a different description
because describing this property as an object isn't quite right.

We probably could extract the export name but that's kind of renderer
specific and I just added this shared module to Fizz which doesn't have
that which is unfortunate an consequence.

For default exports we don't have a good name of what the alias was in
the receiver. Could maybe call it "default" but for now I just call it
"client".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

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

Assignees

No one assigned

Labels

CLA Signed

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.

4 participants

@jon-ressio @sebmarkbage @facebook-github-bot @jonstelly
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.