Skip to content
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

TypeError: Cannot read property 'getInitialProps' of undefined #1808

Closed
sentry-io bot opened this issue Jul 6, 2023 · 11 comments
Closed

TypeError: Cannot read property 'getInitialProps' of undefined #1808

sentry-io bot opened this issue Jul 6, 2023 · 11 comments
Assignees
Labels
0 bug Something isn't working research

Comments

@sentry-io
Copy link

sentry-io bot commented Jul 6, 2023

Sentry Issue: REACT-COMMERCE-2F6

TypeError: Cannot read property 'getInitialProps' of undefined
  at f (app:///_next/static/chunks/main-460f244aa201f592.js:1:102766)
  at K.i.loadPage.then.then.r (app:///_next/static/chunks/main-460f244aa201f592.js:1:9732)
@sterlinghirsh sterlinghirsh added 0 bug Something isn't working research labels Jul 11, 2023
@danielcliu-ifixit
Copy link
Member

async function f(e, t) {
    let r = t.res || t.ctx && t.ctx.res;
    if (!e.getInitialProps) // error is thrown here
        return t.ctx && t.Component ? {
            pageProps: await f(t.Component, t.ctx)
        } : {};
    let n = await e.getInitialProps(t);
    if (r && u(r))
        return n;
    if (!n) {
        let t = '"' + s(e) + '.getInitialProps()" should resolve to an object. But found "' + n + '" instead.';
        throw Error(t)
    }
    return n
}

@danielcliu-ifixit
Copy link
Member

errors appears around the time #1726 was merged. seems possible its not coincidental

@danielcliu-ifixit
Copy link
Member

possibly related vercel/next.js#36221

@federicobadini federicobadini self-assigned this Jul 19, 2023
@federicobadini
Copy link
Contributor

Given this comment and the fact that Next.JS 13 enabled swcMinify by default, turning off swcMinify would be a good test.
One positive thing is that this bug seems to happen only on quite old browsers versions (>> 3 years ago).

@danielcliu-ifixit danielcliu-ifixit self-assigned this Jul 24, 2023
This was referenced Jul 24, 2023
@danielcliu-ifixit
Copy link
Member

danielcliu-ifixit commented Aug 4, 2023

@federicobadini it seems like the error is still happening after updating next js. how do you feel about moving forward with #1846?

@federicobadini
Copy link
Contributor

Yes, let's try that option too.

@federicobadini
Copy link
Contributor

It seems that the error is still present, so it must not be linked to swc either.
Given that nextjs is working more and more on swc, I think it might be worth reverting this.

@danielcliu-ifixit
Copy link
Member

danielcliu-ifixit commented Aug 14, 2023

@federicobadini while it doesn't fix this error it did seem to fix #1797 so i think we should leave this for now.

@federicobadini
Copy link
Contributor

@federicobadini while it doesn't fix this error it did seem to fix #1797 so i think we should leave this for now.

Oh, that's good. So maybe that was swc related while this wasn't.

@federicobadini
Copy link
Contributor

federicobadini commented Jan 18, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 bug Something isn't working research
Projects
None yet
Development

No branches or pull requests

3 participants