-
Notifications
You must be signed in to change notification settings - Fork 47.4k
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
Critical bug at [server side render], failure when use [Context.Consumer] in [production] mode only. #16913
Conversation
Would be nice with a test case as well 🙂 |
As far as I understand, the test is difficult to implement, since the error occurs after the separation files on |
Don't know how, but test will be passed, but after build bug has effect. |
@sebmarkbage @trueadm that code between yours, can you chek it? |
Probably need a test that runs on the production bundle. However I'm not very familiar how that works. Given that it's only the production bundle that has the bug, it might be a minifier bug causing this. |
Maybe, but this PR fix this behavior |
In deep, problem in object structure of react element. I think problem arose by merge conflict. Condition for check this was shifted to dev block. |
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.
Ignore my previous approval, that was by mistake (I went back to the wrong browser tab, oops).
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.
It seems that you're mixing DEV and PROD modes in the same app? You should only have one or the other. Maybe instead we could warn if you're not in DEV but the prod callsite exists, as that would infer there's been a mix up somewhere along the way. It might also be due to mixing contexts from older versions, as per the comment:
Either way, this seems like an issue in the packages you're using rather than an underling issue in React.
@trueadm
as I understand it production mode |
Yes, you right. It is was collision in my bundle. |
Awesome. Glad I could help :) |
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.
Is there any workaround since its difficult to find which one of the context you're using on your application is the one causing the problem. I know that this is a problem regarding other packages, but I would suggest to have an alternative here.
I have same problem and i tried to create simple component with:
And this is working, but if i change value to object, like this:
I get
Both codes are working normally in DEV mode. Any idea what could be wrong? Thanks. |
I realize that i had multiple instances of Context. So when i fixed that, problem went away. |
Hello everyone!
That fix for server side rendering when you use Context.Consumer.
Issues for example in react:
#16848
Issues for example in react-router:
remix-run/react-router#6789
remix-run/react-router#6704
Issues for example in redux-connect:
makeomatic/redux-connect#137
Issues for example in next.js:
vercel/next.js#7167
Bug was in
ReactDOMServerRenderer.js
since version16.6.2
and affects.renderToString
renderToStaticMarkup
renderToNodeStream
renderToStaticNodeStream
To reproduce, only in
production
mode and total bundle, tryAnd you will see just
<span></span>
instead<span>dark</span>