-
Notifications
You must be signed in to change notification settings - Fork 46.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix error handling when name is a Symbol #28354
Conversation
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 We can also special case detecting that this is a ClientReference when printing the error. |
Alternative fix in #28355. |
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! |
You got lucky I was working on improving error messages anyway. 😅 |
…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".
…erence (facebook#28355) Alternative to facebook#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".
…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.
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.