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

Unhandled Runtime Error: ChunkLoadError #56484

Closed
1 task done
rsheppard-dev opened this issue Oct 5, 2023 · 30 comments
Closed
1 task done

Unhandled Runtime Error: ChunkLoadError #56484

rsheppard-dev opened this issue Oct 5, 2023 · 30 comments
Labels
bug Issue was opened via the bug report template. locked

Comments

@rsheppard-dev
Copy link

Link to the code that reproduces this issue

https://github.com/rsheppard-dev/lh-plumbing

To Reproduce

  1. Start application in development.
  2. Refresh page several times.

Or

  1. Load application in production.
  2. Occasionally happens when internet connection speed is low or if navigating between routes quickly.

Current vs. Expected behavior

I expect page page to load normally however in development I get this error:

`Unhandled Runtime Error
ChunkLoadError: Loading chunk app/(app)/layout failed.
(error: http://localhost:3000/_next/static/chunks/app/(app)/layout.js)

Call Stack
webpack_require.f.j
file:///Users/roy/Documents/Code/lh-plumbing/.next/static/chunks/webpack.js (853:29)

/next/static/chunks/webpack.js (155:40)
Array.reduce

webpack_require.e
file:///Users/roy/Documents/Code/lh-plumbing/.next/static/chunks/webpack.js (154:67)
fn.e
/next/static/chunks/webpack.js (391:50)
loadChunk
node_modules/.pnpm/[email protected]
@babel[email protected][email protected][email protected]/node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js (202:31)
preloadModule
node_modules/.pnpm/[email protected]
@babel[email protected][email protected][email protected]/node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js (128:0)
resolveModule
node_modules/.pnpm/next@13.5.5-canary.2_@babel[email protected][email protected][email protected]/node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js (1725:0)
processFullRow
node_modules/.pnpm/next@13.5.5-canary.2_@babel[email protected][email protected][email protected]/node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js (1796:0)
processBinaryChunk
node_modules/.pnpm/next@13.5.5-canary.2_@babel[email protected][email protected][email protected]/node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js (1944:0)
progress
node_modules/.pnpm/next@13.5.5-canary.2_@babel[email protected][email protected][email protected]/node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js (2024:0)`

If I refresh again page loads normally. In production I got a full page of text like this:

0:["8cuD6kwHKIa0es9d4FAUU",[[["",{"children":["(app)",{"children":["__PAGE__",{}]},"$undefined","$undefined",true]}],"$L1",[[],"$L2"]]]] 3:HL["/_next/static/media/e1c529c04de64b40-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}] 4:HL["/_next/static/media/e7c7dbb62ddcf6fa-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}] 5:HL["/_next/static/css/09cb01cb14dd5f8d.css","style"] 6:I{"id":90287,"chunks":["272:static/chunks/webpack-153c1757a1b8d488.js","158:static/chunks/40519c47-39d723cc761f5bdf.js","981:static/chunks/981-d0de02e3ea918bed.js"],"name":"","async":false} 7:I{"id":28695,"chunks":["272:static/chunks/webpack-153c1757a1b8d488.js","158:static/chunks/40519c47-39d723cc761f5bdf.js","981:static/chunks/981-d0de02e3ea918bed.js"],"name":"","async":false} 1:["$","$L6",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","template":["$","$L7",null,{}],"templateStyles":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI ........

Verify canary release

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

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000
Binaries:
  Node: 20.3.1
  npm: 9.6.7
  Yarn: N/A
  pnpm: 8.6.12
Relevant Packages:
  next: 13.5.5-canary.2
  eslint-config-next: 13.4.19
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure, App Router

Additional context

I am hosting my Next site on Netlify. This error has happened in production on a MacBook Pro and iPhone 13 Pro using Chrome.

I have also had this happen on Safari.

@rsheppard-dev rsheppard-dev added the bug Issue was opened via the bug report template. label Oct 5, 2023
@ArianHamdi
Copy link
Contributor

We have recently encountered some random crashes when changing routes after upgrading to version 13.5.1. I am not sure about the exact cause, but the page becomes stuck during the route change. In Chrome, it displays an 'Aw, snap!' crash error, while Firefox indicates that the site is slowing down your browser.

We are currently deploying on Amplify AWS.

@khalilsarwari
Copy link

This is happening for us in production when leaving the landing page for the following resource:

_next/static/chunks/webpack-8147f10d25df47dc.js
Request Method:
GET
Status Code:
404 Not Found

@rahulknagori
Copy link

rahulknagori commented Oct 6, 2023

Facing the same issue in production. Only the pages using CMS/revalidate feature crashes. The issue is most probably in server page.tsx files. Everything works fine in local. This happened when I updated the app to the latest 13.5.5 canary version. Reverted the version to 13.4.1 and now everything works fine even in production.

@max-mayorov
Copy link

Having the same issue in production...

@ArianHamdi
Copy link
Contributor

I have found the culprit that is causing the error but I don't know how to fix it easily.

My layout is a server component. My header component in layout.tsx is a server component but that includes a client component for my mobile menu as I use useState to manage the state of my menu. If this is a server component there is no issue but then I can't have a mobile menu functioning.

We are on page router

@rsheppard-dev
Copy link
Author

I have changed my hosting to Vercel and so far I haven't had the issue. It appears this is a Netlify issue not a Next issue which I'm glad about cause I love Next but this was making it unusable. Hopefully Netlify fix this. Will keep testing my production app and hopefully it carries on working.

@johnrackles
Copy link
Contributor

So we got this error after upgrading to 13.5.5, in development and deployed to vercel in production. Downgrading to 13.5.4 fixed it

@khalilsarwari
Copy link

@huozhi not sure if you guys have seen this yet, but this does seem to be a pretty significant issue (can't upgrade without it since the site doesn't load).
There is some activity here as well: #38507

@jesse-mm
Copy link

jesse-mm commented Oct 23, 2023

Same kind of issue here, I have catch-all in my root [...foo] and for me _next assets are not loading but rather loading the catch-all page. Reverted back to 13.5.4 which works for me.

Due to this issue also navigation "crashes" as mentioned earlier in the comments.

@enijar
Copy link

enijar commented Oct 26, 2023

@johnrackles's solution is currently the only fix for this. We were experiencing the exact same issue. The issue we discovered was due to encoded dynamic routes [locale].

This URL was what Next.js was requesting which 404'd:
http://localhost:3000/_next/static/chunks/app/%255Blocale%255D/resources/page.js

But manually URL decoding the URL and opening in a new tab correctly resolved the file:
http://localhost:3000/_next/static/chunks/app/[locale]/resources/page.js

We were experiencing this issue on [email protected], but downgrading to [email protected] resolved the issue, so there's definitely been a bug that's been released in version [email protected] or later.

@abilal82
Copy link

Had same issue in localhost. I just delete .next folder restart the application and issue resolved. error occurred when i changed routing hierarchy. now its working fine.
NOTE: This is only applied in development mode, I didn't face this sort of issue on production.

@patotoma
Copy link

Noticed the same thing as @enijar. The app is trying to load:
.../chats/%255BchatId%255D/page-...
which results in 404

but if I update the url manually to
.../chats/[chatId]/page-...
it works

Current version: 13.5.6

@timhonders
Copy link

I think the problem is that the page.js url is double encode

When you url decode:

http://localhost:3000/_next/static/chunks/app/%255Bstorecode%255D/page.js

you get

http://localhost:3000/_next/static/chunks/app/%5Bstorecode%5D/page.js

And it only happens when navigating.

Checked 14.0.0, it still happening

@rahul3v
Copy link

rahul3v commented Oct 29, 2023

Facing the same issue, revert back to v13.5.4

@alvarlagerlof
Copy link

alvarlagerlof commented Oct 30, 2023

I've tried making a reproduction for the issue mentioned in the lower comments here, specifically double encoding of [ and ], but I failed. Since there isn't one in this issue, I would encourage anyone who's also having this issue to make one and share a repo link for it if you are able to. For is, the issue only appears on soft navigations.

@rbkayz

This comment has been minimized.

@huozhi huozhi added the please add a complete reproduction The issue lacks information for further investigation label Oct 31, 2023
@huozhi
Copy link
Member

huozhi commented Oct 31, 2023

Can someone post a reproduction of this? The origin reproduction in the issue description is 404

@github-actions
Copy link
Contributor

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 please add a complete reproduction label?

To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository (template for App Router, template for Pages Router), but you can also use these templates: CodeSandbox: App Router or CodeSandbox: Pages Router.

To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as minimal as possible. This means that you should remove unnecessary code, files, and dependencies that do not contribute to the issue. Ensure your reproduction does not depend on secrets, 3rd party registries, private dependencies, or any other data that cannot be made public. Avoid a reproduction including a whole monorepo (unless relevant to the issue). The easier it is to reproduce the issue, the quicker we can help.

Please test your reproduction against the latest version of Next.js (next@canary) to make sure your issue has not already been fixed.

If you cannot create a clean reproduction, another way you can help the maintainers' job is to pinpoint the canary version of next that introduced the issue. Check out our releases, and try to find the first canary release that introduced the issue. This will help us narrow down the scope of the issue, and possibly point to the PR/code change that introduced it. You can install a specific version of next by running npm install next@<version>.

I added a link, why was it still marked?

Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "example.com", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.

What happens if I don't provide a sufficient minimal reproduction?

Issues with the please add a complete reproduction label that receives no meaningful activity (e.g. new comments with a reproduction link) are automatically closed and locked after 30 days.

If your issue has not been resolved in that time and it has been closed/locked, please open a new issue with the required reproduction.

I did not open this issue, but it is relevant to me, what can I do to help?

Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps. Furthermore, you can upvote the issue using the 👍 reaction on the topmost comment (please do not comment "I have the same issue" without reproduction steps). Then, we can sort issues by votes to prioritize.

I think my reproduction is good enough, why aren't you looking into it quicker?

We look into every Next.js issue and constantly monitor open issues for new comments.

However, sometimes we might miss one or two due to the popularity/high traffic of the repository. We apologize, and kindly ask you to refrain from tagging core maintainers, as that will usually not result in increased priority.

Upvoting issues to show your interest will help us prioritize and address them as quickly as possible. That said, every issue is important to us, and if an issue gets closed by accident, we encourage you to open a new one linking to the old issue and we will look into it.

Useful Resources

@enijar
Copy link

enijar commented Oct 31, 2023

Here's a repro of this error:

https://github.com/enijar/next-load-error-repro

Notice that somehow including this third party script causes the issue:

<Script
  strategy="beforeInteractive"
  src="https://cdn.cookielaw.org/scripttemplates/otSDKStub.js"
/>

@jianliao
Copy link

jianliao commented Oct 31, 2023

@huozhi Here is a more detail bug reported by me #57829. Please check the Additional context section.

@jianliao
Copy link

As a workaround, you can remove beforeInteractive to avoid this issue.

@enijar
Copy link

enijar commented Oct 31, 2023

Removing beforeInteractive fixes this issue. This is 100% still a bug as adding beforeInteractive shouldn't cause that behaviour.

@omateusanjos
Copy link

Removing beforeInteractive fixes this issue. This is 100% still a bug as adding beforeInteractive shouldn't cause that behaviour.

Bro, you saved our life. Thank you.

markspolakovs added a commit to ystv/badger that referenced this issue Nov 2, 2023
markspolakovs added a commit to ystv/badger that referenced this issue Nov 2, 2023
* Next 13.5.7

* Dedupe

* Desktop E2E unbreaking

* Work around vercel/next.js#56484
ajitnaik pushed a commit to ajitnaik/pawsome-fe that referenced this issue Nov 2, 2023
@gnoff
Copy link
Contributor

gnoff commented Nov 2, 2023

@jianliao thanks for the repro

@huozhi huozhi removed the please add a complete reproduction The issue lacks information for further investigation label Nov 3, 2023
@huozhi
Copy link
Member

huozhi commented Nov 3, 2023

We land a fix for #57829 and also the one mentioned related to next/script in v14.0.2-canary.9, please upragde and let us know if your issue is resolved, thanks!

@alvarlagerlof
Copy link

I tested the canary locally and can confirm that it the fix works with the Script strategy="beforeInteractive" 🥳

@jianliao
Copy link

jianliao commented Nov 3, 2023

@huozhi Thanks for the quick fix. I can confirm it works on 14.0.2-canary.10 now.

@huozhi huozhi closed this as completed Nov 7, 2023
@feliche93
Copy link

@huozhi I am still getting an error on 14.0.2 and also latest canary [email protected]:

For some reason 14.0.1 is working without any errors.

Running pnpm dev everything works with no errors shown.

When I build locally or deploy and navigate from / to /backlink-prospects (packages/frontend/src/app/(app)/(paid)/backlink-prospects) via a <Link/> component I get the following error:

Application error: a client-side exception has occurred (see the browser console for more information).

When I check the console, I see the following:

ChunkLoadError: Loading chunk 3781 failed.
(missing: http://localhost:3000/_next/static/chunks/3781-32a3a102dc80bd51.js)
    at s.f.j (webpack-20ebb4fb329d62fa.js:1:3964)
    at webpack-20ebb4fb329d62fa.js:1:1427
    at Array.reduce (<anonymous>)
    at s.e (webpack-20ebb4fb329d62fa.js:1:1393)
    at 3815-619463d83fe0fd94.js:6:15126
    at 3815-619463d83fe0fd94.js:6:15328
    at t (3815-619463d83fe0fd94.js:6:15531)
(anonymous) @ 3815-619463d83fe0fd94.js:1

When I refresh the route the page loads without any problem, but a tanstack-table client component is unresponsive, e.g. clicking and everything doesn't do anything.

Let me know if I should open a new issue or can provide any more info.

@huozhi
Copy link
Member

huozhi commented Nov 11, 2023

@feliche93 please open a new issue with reproduction, thanks

Copy link
Contributor

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked
Projects
None yet
Development

No branches or pull requests