question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Split chunk fails to load with undefined hash

See original GitHub issue

Bug report

What is the current behavior?

Certain chunk requests use undefined instead of the hash. Example of the resulting error in chrome:

Uncaught (in promise) Error: Loading chunk 63 failed.
(error: https://{hostname}/app/63.undefined.feasContentHashV1.chunk.js)
    at HTMLScriptElement.i ({appName}.d5b0c78176fe6ff82a0f.bundle.js:1)

The request for chunk 63 looks like this:

https://{hostname}/app/63.undefined.chunk.js

Stepping through the webpack build, it appears as though the function getScriptSrcPath in JsonpMainTemplatePlugin.js (link) creates a mapping of chunk Id to hash. Looking at the result, the entry for the chunk Id 63 is missing entirely, resulting in the undefined hash in the request.

However, looking through the resulting build, there appears to be a valid chunk 63 with a valid hash in the file name. I’m guessing that somewhere along the line, the reference is lost to this chunk?

If the current behavior is a bug, please provide the steps to reproduce.

This is somewhat difficult to reproduce, I think its related to the total number of async chunks made by splitChunksPlugin, but I’m not 100% sure. I’m unable to reproduce a build that can do this. please let me now what other information would be useful.

I think this may be related to https://github.com/webpack/webpack/issues/7061 since the behavior sounds similar. However, according to the maintainers that bug was fixed in 4.6.0. Since we are at a later version (4.29.0) I would expect that fix to be included.

What is the expected behavior?

I would expect JsonpMainTemplatePlugin to produce code that has a valid mapping of all chunk Id’s to their respective hashes, and for all requests for chunks to have defined hashes.

Other relevant information: webpack version: 4.29.0 (I also tried linking to a develop build of webpack) Node.js version: v8.11.1 Operating System: MacOS Additional tools:

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:35 (12 by maintainers)

github_iconTop GitHub Comments

7reactions
arcaniscommented, Sep 16, 2020

I found a reproduction! Can this issue be reopened? The following repository triggers the bug if you follow the instructions:

https://github.com/arcanis/webpack-project-generator

6reactions
sokracommented, Sep 16, 2020

Thanks @arcanis I think I can fix that… Tomorrow…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack Code Splitting 'Loading chunk failed' error wrong ...
When you use code splitting with React.lazy, sometimes a 'chunk load error loading chunk 4 failed in react' error will occur.
Read more >
What they don't tell you about webpack dynamic imports
Webpack code splitting: ChunkLoadError - Loading chunk X failed, but the chunk exists. I've integrated Sentry with my website a few days ago ......
Read more >
SplitChunksPlugin
Meaning if splitting into a chunk does not reduce the size of the main chunk (bundle) by the given amount of bytes, it...
Read more >
API - ESBuild
Adding [hash] to your entry point names means esbuild will calculate a hash that relates to all content in the corresponding output file...
Read more >
How to solve missing chunk code splitting errors after deploy
The pitfall that results in the error we talk about here comes when you deploy your application. On deploy a new build is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found