This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Cannot read properties of undefined (reading 'getInitialProps') #36221
Comments
I found, if some function uses 'zlib' module in app.ts, and swcMinify=true in next.config.js, this error comes like above; If swcMinify=false, page is ok and no error. So then zlib will not be supported after next 12.1.0? |
Seeing the same. Setting |
Is this issue still the case? |
Is this fixed in next 12.3? |
@davidhanlonJCM I think so, but I can't verify as there's no input nor repro case. |
@kdy1 upgrading to next 12.3 appears to have solved the issue for me. In my case the issue appeared when using next 12.1 with |
in version v13, if I run production (npm run build && npm run start) version I get these errors. if dev - all fine :| |
@DonikaV Can you provide a repro? |
i've been getting the same errors in my sentry report. using next 12.3.1 I've already tried to disable swcMinify. i use getInitialProps once only in
My sentry report:
Consequently seems like some users are getting and others not. any ideas? |
@rossignolli Can you try 12 canary? |
No, the problem that I don't use anywhere any functions like getInitiallProps. I only use env vars. maybe it because of that, but in version 12* all works fine. In 13 no :| |
Same :/ |
Oh if disabling swcMinify does not work it's a different issue |
after I disabled swcMinify works well. But is weird why it is happening :) @kdy1 |
@DonikaV I can't debug without a repro |
@rossignolli have you already resolved your problem? I faced the same :( |
Analyzing my sentry report I notice that most of errors come from outdated or unsupported browsers versions. But i still trying to figure out a solution. |
Also having this issue with 13.0.2 Production Builds using getStaticProps are failing on Vercel are failing with the error:
...but I can do production builds locally. swcMinify: false does not fix the error. I am also using a custom _document to inject serverside styles, but using Emotion. My _document file:
Is the custom _document the common theme? |
UPDATE: Having disabled the part of _document with getInitialProps, and removed the other reference to getInitialProps in my app (inside the Sentry Error Handler), I still get this error. |
@kdy1 Sorry, don't have this anymore. I meanwhile checked the web and implemented a solution that works for me now without making compromises and by using getInitialProps in _app without any error: https://jools.dev/server-side-auth-with-nextjs-context-and-hooks. |
I removed
|
FYI I also came across this error, straight after I added Sentry to my Next.js v12 project.
After digging around a bit, I realized that I didn't had a tl;dr: Verify, that your |
This is occurring for us with next 12.3.4: Debugging has lead me to: next.js/packages/next/shared/lib/utils.ts Line 362 in 4ca12bd
App is undefined and as such is unsafe to call Looking at it - this may be related to the async to generator transformations somehow... |
Thanks, this solved my issue. I downgraded
|
Hey everyone, any updates on this? |
Not sure if this is a related issue or not, but I recently upgraded node 14->18 and the various issues I had went away - see #45052 (comment) |
I got same issues as above. Downgrading Sentry to 7.12.1 fixed. Was on 7.37.2 so not fixed there. |
Can't confirm yet, but believe my case will be addressed by getsentry/sentry-javascript#6572 (comment) |
I was facing the same issue, tested the different fix approaches mentioned in this thread but none of them worked... So I started debugging branch commits one by one and found out the root cause of this error triggering in Cypress CI process was related to a code change I made to a index.ts file in the project. Basically, this index.ts file does the following inside the folder it is inserted: export * from './component-1' My error was updating the order of this exports, after undoing the order changes I made, the error was gone. |
I have tried everything posted in this discussion and I still get the error. I last tried to downgrade from Next 13 to 12 and from @sentry/next 7.43 to 7.12.1. I hoped this one would solve it but the error still shows in Sentry. This not only affects older browsers as some people have pointed out, but I've also seen users in the latest MacOS and Safari version having this issue and it doesn't allow them to navigate in the app. Is anyone still having this issue after trying out all the options? |
Still having this issue, seeing it sentry affect users using the below:
|
It still occurs in the following environments.
I tried upgrading to the latest version of @sentry/nextjs 7.53, but it didn't help much. I don't think we've figured out exactly what the problem is yet. |
Is anyone having the same issue with TRPC as a wrapper around their app? |
Any update? Seems like a simple |
Turns out my issue was related to import statements. I am using a mono repo which had a lot of circular dependencies causing the build to have problems but everything works fine after creating a dependency graph and moving things around |
Leaving this comment for all those still experiencing the issue. Same as stated in this comment, I started to experience the issue right after adding Sentry to my Next v12 project. Changelog report for test: new RegExp(`^${escapeStringForRegex(pagesDirectory)}.*\\.(${pageExtensionRegex})$`), This change was significant in my case since my project contained both Not completely familiar with how sentry boostraps in Next but renaming my ps. after this renaming, my projects is ok even with latest |
I also experienced this, but my project contained a |
This started in one of our projects. I found a colleague had added (most likely auto-added on accident):
removing that fixed it |
In my case the problem is fixed defining an |
@dlvx , @JClackett and @rossignolli do any of you have an update on this or a workaround? My issue affects ios devices on browser "Mobile Safari UI/WKWebView" |
Turns out I needed just enough time and headache to troubleshoot this.
|
Hi everyone, I will be moving this to Thank you for all the different solutions and reports! If the issue continues to arise, I encourage folks to create a separate bug report for their issue. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Verify canary release
Provide environment information
next: 12.1.1-12.1.6-canary.2
react: 17.0.2 or 18.0.0
node: 14.19.1
system: windows
What browser are you using? (if relevant)
chrome 100.0.4896.88
How are you deploying your application? (if relevant)
next start
Describe the Bug
Expected Behavior
no error in console and display page content
To Reproduce
Then npm run build, everything is ok and built successfully.
Now npm run start, get error like this in console (see image attached) and there is nothing displaying in browser, just blank:
A client-side exception has occurred, see here for more info: https://nextjs.org/docs/messages/client-side-exception-occurred
Error rendering page: TypeError: Cannot read properties of undefined (reading 'getInitialProps')
No error if next 12.1.0 and more lower version.
The text was updated successfully, but these errors were encountered: