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.

Inevitable unhandled Promise rejection due to failure of prefetch

See original GitHub issue

Bug report

TL; DR: Promise without .catch here.

What is the current behavior?

If you dynamic-import a chunk and that chunk tries to prefetch another chunk, and that prefetch fails for some reason, you get an unhandled Promise rejection reported even if you are doing proper error handling.

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

Here is a reproduction repo: https://github.com/uhyo/webpack-prefetch-rejection-repro

  1. Build by npx webpack.
  2. Open index.html.
  3. You see an unhandled Promise rejection reported. スクリーンショット 2021-09-02 23 10 22

The repro includes a custom Webpack plugin (BoomPlugin) that simulates a failure of loading of accompanying resources. Of course, this is just for easily reproducing the issue; the case I actually faced involved mini-css-extract-plugin trying to load a CSS chunk accompanying main chunk.

What is of note is that all import() calls included in source code properly handles Promise rejections. The above image shows how a prefetch failure error is handled by import(...).catch but is still reported as a Promise rejection via another path.

Seems that this unhandled Promise rejection is inevitable; the rejecting Promise is created internally in Webpack runtime and there is no way of preventing that.

What is the expected behavior?

Properly handle the error internally, or provide a way to register a .catch handler to the internal Promise.

Other relevant information: webpack version: 5.51.1 Node.js version: 14.15.0 Operating System: MacoS Mojave 10.14.6 Additional tools:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:22 (17 by maintainers)

github_iconTop GitHub Comments

3reactions
alexander-akaitcommented, Sep 2, 2021

You can solve this on your application side

2reactions
alexander-akaitcommented, Mar 25, 2022

@vankop Can you look at this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is an unhandled promise rejection? - Stack Overflow
A rejected promise is like an exception that bubbles up towards the application entry point and causes the root error handler to produce...
Read more >
Handling those unhandled promise rejections with JS async ...
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was ......
Read more >
All Reports with description - SQLite CVSTrac
Changing the name of the rollback journal and especially moving it to a different volume can lead to database corruption following a power...
Read more >
Learning React
When a promise is rejected, any details are passed back to the catch function, or the catch block if using async/await syntax: getPeople(5)....
Read more >
HTML 5.3: 4.7. Embedded content - W3C
If decoding fails, reject promise with an " EncodingError ... Provide an alt attribute for each linked image to describe the purpose of...
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