-
Notifications
You must be signed in to change notification settings - Fork 27k
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
[NEXT-1103] Cannot read properties of null (reading 'useState') with Context Wrapper #48518
Comments
This is now happening when upgrading
in the message, but all other hooks coming from The builds are failing only when deployed on Vercel. |
The same thing happens on v13.4.0 with self-hosted apps. |
Have you tried latest patch 13.4.1 as we had a fix for that included in the patch? People mentioned in the thread that fixed their issue? |
I am experiencing the same issue with version 13.4.1. |
@huozhi I have upgraded the demo to 13.4.1, tried building, and unfortunately it is still failing with the same err... |
As an aside, I'm using pages routing and it happened in a development environment, not a build environment. |
Same thing here, the build works locally, but fails on vercel. |
Any solution? I am getting the same since one week, using next 13.2.5 |
Hi, another dev trying to use app dir alongside existing pages on a production app here. I can reproduce this error using latest relevant packages: "next": "^13.4.2",
"react": "^18.2.0",
"react-dom": "^18.2.0", Build does only fail on Vercel, local Specifics We encountered this issue with swiper package, however the specific package is irrelevant, it's caused probably by Next bundling the third-party packages. This package is used only in pages routes. Workaround I added this package to transpilePackages which made the build finish. Similar issues |
For the original bug reproduction (https://github.com/Kiwi-Biosciences/debug), the cause was using async components inside a "use client" file, which is disallowed. |
Older versions are also not working for me, btw I am deploying the changes into AWS Lambda Serverless Stack |
Same issue here. App runs locally on NextJS 13.4.x, but fails with the same error after deploying to Lambda via SST. I am using 'next-auth', which I believe uses a Context wrapper. My Downgrading NextJS did not solve. Edit:
|
@benry1 Yes, exactly same behavior I am experiencing. |
#50158 is this issue related? Literally getting the same issue with the pages directory. Any update on this? |
Can someone provide a full reproduction here if the issue still exists or can confirm the issue is gone with latest canary? |
We cannot recreate the issue with the provided information. Please add a reproduction in order for us to be able to investigate. Why was this issue marked with the
|
@huozhi Please find my minimal reproduction here: This requires SST to show the failure, but I am not sure if this is a NextJS or an SST issue. |
@benry1 have you tried with the canary version? it's still using the latest. Please provide a minimal reproduction that can be deploy on codesandbox or can develop locally, the one you linked requires aws credentials etc. |
I tried the same after building the latest canary version locally, had the same issue. I wasn't sure how to embed that into the repo, so I left it as latest. I can't reproduce this locally, it only happens when deployed on AWS, but it happens very consistently. Testing it will require aws credentials unfortunately. If that's not sufficient, feel free to re-tag this with |
Update: My issue was an SST related issue. It was using an incorrect version of open-next, this has been solved in SST 2.10.1. |
@benry1 I think I have run into the same issue but updating SST and any combination of next/next-auth isn't working for me. Any chance you could add some notes on how you debugged this and how you got the fix to work? |
I'm running into this issue on local builds. I'm not using sst: Reproduced on this codesandbox: Define the starting process: npx nx serve twilio-cli |
@dprothero I was able to reproduce the error with your CodeSandbox. I've tried a variety of version combinations and was still running into issues. In the end downgrading Next to ~13.2.4 solved it for me. There is likely another version in between that works. I've tested the latest canaries and still see the issue. In the end
Another note for the SST case. The deployment between newer and older versions changed pretty dramatically and the caching made things tough to debug. Hitting the lambda url directly made everything considerably easier. I was never able to reproduce this locally in any configuration. |
Few related fixes are released in 13.4.4, please try to upgrade to latest and test to see if the issue still existed. Will close this issue as there's no new reproduction testing against latest canary. If you still bumped to troubles, please file a new issue with minimal reproduction with latest canary. |
@huozhi No, the problem still exists with 13.4.4: |
Thanks @jeffrafter, downgrading to Next 13.2.4 did work for now. Hopefully Next and/or Nx can solve this issue. |
@dprothero can you provide some repro steps? couldn't download from codesandbox and I found the repo, but there's no steps in readme how to start and how to repro the errors |
Sorry for missing the steps here. Looking into it |
@dprothero it's a nx problem for their current latest version (16.2.2) as they set function withNx(_nextConfig = {}, context = getWithNxContext()) {
// If this is not set user will see compile errors in Next.js 13.4.
// See: https://github.com/nrwl/nx/issues/16692, https://github.com/vercel/next.js/issues/49169
// TODO(jack): Remove this once Nx is refactored to invoke CLI directly.
forNextVersion('>=13.4.0', () => {
var _a;
process.env['__NEXT_PRIVATE_PREBUNDLED_REACT'] =
// Not in Next 13.3 or earlier, so need to access config via string
((_a = _nextConfig.experimental) === null || _a === void 0 ? void 0 : _a['serverActions']) ? 'experimental' : 'next';
}); Looked at their code it's remove in the code, but not published yet. I think you can wait for the next version or switch to a nx version without |
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: darwin Arch: arm64 Version: Darwin Kernel Version 22.4.0: Mon Mar 6 21:00:41 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8103 Binaries: Node: 19.1.0 npm: 8.19.3 Yarn: N/A pnpm: N/A Relevant packages: next: 13.3.1-canary.11 eslint-config-next: 13.3.0 react: 18.2.0 react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Data fetching (gS(S)P, getInitialProps)
Link to the code that reproduces this issue
https://github.com/Kiwi-Biosciences/debug
To Reproduce
When trying to build the project, it will fail with the following error:
TypeError: Cannot read properties of null (reading 'useState')
Describe the Bug
The build fails.
Expected Behavior
The build should succeed, as there are no visible logic or syntax errs.
Which browser are you using? (if relevant)
Firefox 112.0
How are you deploying your application? (if relevant)
AWS Amplify
NEXT-1103
The text was updated successfully, but these errors were encountered: