-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
"Error: Cannot read properties of null (reading 'useContext')" in standalone server #51482
Comments
Error: Cannot read properties of null (reading 'useContext')
Seems to be caused by the changes in #51172. |
@shehi Are you seeing errors in pages/ or app/? |
@huozhi I just encountered this bug, in an app using edit: Added stacktrace
|
@alexanbj Thanks for provding the info, will investigate it asap |
I have the same problem, also solved by downgrading to 13.4.5. If another stacktrace helps, I'd be happy to post it, but it's basically the same as above, except for the third line (which refers to a different dependency). |
`/pages`. Isn't `/apps` still a beta?
|
Can't repro that easily with simple setup with SWR SSR in |
I've got one right here: https://github.com/Breuls/next-issue-51482 It looks like the minimal steps I needed were:
Even though useTranslation is the next step in the error trace, I needed the SSP function to actually trigger it. |
Request data flow in the server ``` request ---> router worker (1) ---> ipc ---> render worker app (2) |-----> render worker pages (3) ``` When it's hitting `_next/*` unmatched routes in standalone server, it will render 404, but when you hit `_next/*` it will render app not-found as the app router is always enabled, but router worker isn't set up with require-hook for proper built-in react version, then the app-render will fail with `./server.edge` exports not found error. We detect if it's in the render worker, then do the app paths rendering instead of directly looking up for app paths in route worker. This could avoid unexpected accesses to the app-render Fixes #51482 Fixes #50232 Closes #51506 Reverts changes in #51172 fix NEXT-1260
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. |
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #82-Ubuntu SMP Tue Jun 6 23:10:23 UTC 2023 Binaries: Node: 18.16.0 npm: 9.5.1 Yarn: N/A pnpm: N/A Relevant packages: next: 13.4.7-canary.1 eslint-config-next: 13.4.6 react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.3
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue or a replay of the bug
N/A
To Reproduce
Unfortunately I can't share any code - my app is not open source.
I can give some points tho:
next/image
, Image Optimization.SWRConfig
. My layout and all providers are wrapped bySWRConfig
.Describe the Bug
While my whole app is working quite flawlessly in NextJs v13.4.5, it broke once I upgraded to v13.4.6. The same error continues in the latest canary.
Following error started to popup across board:
This is happening only on
production
and only when I run app vianode server.js
instead ofnpm start
(standalone
output recommends the former). Duringnpm run dev
ornpm start
everything works fine.Expected Behavior
As in v13.4.5, I shouldn't be getting the aforementioned errors which only happen in v13.4.6.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
node start.js (
standalone
output)The text was updated successfully, but these errors were encountered: