-
Notifications
You must be signed in to change notification settings - Fork 823
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
Strategy unhandled rejection #3320
Conversation
Fully approve of the intent of the PR. However, I don't think |
doneWaiting throws on the first rejected promise that it encounters. This means that subsequent rejected promises may result in unhandled rejection errors. Fixes #3171
1d1c330
to
f5c41d4
Compare
I'll note that |
Thanks for the feedback, @westonruter (and @tomayac). Since |
@joshkel Yes, that makes sense to me, since |
As discussed in code review, this is widely available. Update tsconfig.json to recognize it.
@westonruter I've switched to the native version. Thanks again. |
let promise; | ||
while ((promise = this._extendLifetimePromises.shift())) { | ||
await promise; | ||
while (this._extendLifetimePromises.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the while
loop needs to be retained in case additional promises are added to the array while awaiting the ones that were removed during the first iteration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. (That was my rationale, at least.)
On a related note, I just recalled that the Browser Support page indicates that only the current version minus 2 are to be supported. This is now clearly the case for |
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.