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

Strategy unhandled rejection #3320

Open
wants to merge 4 commits into
base: v7
Choose a base branch
from

Conversation

joshkel
Copy link
Contributor

@joshkel joshkel commented Apr 27, 2024

Fixes #3171

StrategyHandler.doneWaiting throws on the first rejected promise that it encounters. This means that subsequent rejected promises may result in unhandled rejection errors.

Promise.allSettled is a natural solution. It does not appear to be supported on all browsers that workbox uses. (However, I'm having trouble finding a clear statement of what browsers workbox supports, so I could be wrong.) I tried installing promise.allsettled from NPM but had trouble getting the default import from that module to work correctly with Rollup, and I noticed that the workbox service worker libraries tend to avoid external dependencies in general, so I created a local version instead. I put it under workbox-core's _private directory, following the example of other utility code such as Deferred. If I should handle this differently, please let me know.

This is a rebase of #3172 against the v7 branch.

doneWaiting throws on the first rejected promise that it encounters.  This means that subsequent rejected promises may result in unhandled rejection errors.

Fixes GoogleChrome#3171
@tomayac
Copy link
Member

tomayac commented Apr 30, 2024

Fully approve of the intent of the PR. However, I don't think Promise.allSettled() needs polyfilling looking at browser support. Looking at devices that didn't make the Safari 13 cut, this are iPhone 5S, iPhone 6 and 6 Plus, the original iPad Air, the iPad mini 2 and iPad mini 3, and the 6th-generation iPod Touch. For Chromebooks, we'd be locking out Chromebooks stuck on Chrome <76. @tropicadri, what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StrategyHandler.doneWaiting may result in unhandled promise rejections
2 participants