Skip to content
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

Generated class labels in dev do not match server render causing a react error #2226

Closed
nathanmarks opened this issue Jan 26, 2021 · 1 comment · Fixed by #2534
Closed

Generated class labels in dev do not match server render causing a react error #2226

nathanmarks opened this issue Jan 26, 2021 · 1 comment · Fixed by #2534

Comments

@nathanmarks
Copy link

nathanmarks commented Jan 26, 2021

EDIT: the main reason for this happening in my case is that the components in the package are anonymous functions inside forwardRef and the name cannot be resolved for other purposes as well such as react dev tools locally (fixing that resolves the issue as the client and server both pull the correct name from the stack). While this should be fixed, I still think a way to disable the functionality below would be useful should anything similar arise again.


In local dev, where we get react errors for client/server mismatch, emotion is causing issues with some of our components.

We have a number of components in a separate package, and due to what I presume to be some slight differences in our server build and our client build, and how the stack traces are built on the server, we end up with a classname mismatch due to this code:

if (process.env.NODE_ENV !== 'production') {
const error = new Error()
if (error.stack) {
// chrome
let match = error.stack.match(
/at (?:Object\.|Module\.|)(?:jsx|createEmotionProps).*\n\s+at (?:Object\.|)([A-Z][A-Za-z0-9$]+) /
)
if (!match) {
// safari and firefox
match = error.stack.match(/.*\n([A-Z][A-Za-z0-9$]+)@/)
}
if (match) {
newProps[labelPropName] = sanitizeIdentifier(match[1])
}
}
}

I put a breakpoint on the code linked above to see what's going on. Here's a client stacktrace example for a problem component:
image

Here's the stack on the server:
image

So the server generates a class name with -Object at the end, and the client doesn't attach a label at all.

Until this is resolved, is there any way to disable this functionality? This is preventing us from exposing other client server render mismatch errors easily

@fracture91
Copy link

The root cause is probably covered in #2134 / #2136 - but I agree a feature toggle would be nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants