question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Server-side rendering not working on production in next@12.1.6

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System: Platform: Windows Arch: x64 Version: 20H2 Binaries: Node: v14.17.6 npm: 8.1.3 Yarn: 1.22.17 Relevant packages: next: 12.1.6 react: 17.0.2 react-dom: 17.0.2

What browser are you using? (if relevant)

Chrome 102.0.5005.115

How are you deploying your application? (if relevant)

next build

Describe the Bug

When using server-side rendering with next@12.1.6, the context doesn’t get passed down to the children component. When trying to log the context value, the context gets logged on the client-side but not on the server-side.

NOTE: This issue cannot be reproduced with other versions of nextjs and is only specific to 12.1.6. The issue also gets resolved when upgrading react to the latest version i.e. 18.2.0. This works with next dev but fails with next build && next start.

Expected Behavior

The context should get passed down to the children on the server-side in production.

Link to reproduction

https://github.com/sc-addypathania/nextjs-bug-repro/tree/main

To Reproduce

  1. npm run build
  2. npm run start
  3. Check the console/terminal the context is coming out to be undefined whereas its getting logged correctly on the browser

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

1reaction
Klemensascommented, Jul 8, 2022

Encountered the same bug, just with next@12.2.1. Using react-intl and it’s injectIntl helper results in the problematic behavior. This might be the same bug as described here https://github.com/vercel/next.js/issues/38332

Can confirm latest react addresses this, but I’m not ready yet to upgrade. Quite a nasty surprise and took a while to figure out what was happening 😞 if the fix isn’t trivial it would be nice to have it mentioned in the migration guide so others can save time

0reactions
github-actions[bot]commented, Sep 1, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server-side rendering not working on production in Next.js ...
When using server-side rendering with next@12.1.6, the context doesn't get passed down to the children component.
Read more >
Server side rendering not work on production build Next.js
I run next export to build the app, it works and i able to run it on my hosting server. But the problem...
Read more >
Build a server-rendered React app with Next.js and Express
One solution was to render the JavaScript files from the server before returning its output to the server. Example of server-side rendering.
Read more >
SSR vs SSG in Next.js – a practical overview for CTOs and devs
Server -side rendering and static site generation are both useful for improving app interactivity and SEO. Check out this SSR vs SSG in...
Read more >
How to Build Scalable Architecture for your Next.js Project
"Next.js gives you the best developer experience with all the features you need for production: hybrid static & server rendering, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found