Merge pull request #11497 from Snuffleupagus/Promise-allSettled

Add support for `Promise.allSettled`
This commit is contained in:
Tim van der Meij 2020-01-22 23:06:54 +01:00 committed by GitHub
commit 668a29aa45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View File

@ -230,11 +230,7 @@ if (
// need to be polyfilled for the IMAGE_DECODERS build target.
return;
}
if (
globalThis.Promise &&
globalThis.Promise.prototype &&
globalThis.Promise.prototype.finally
) {
if (globalThis.Promise && globalThis.Promise.allSettled) {
return;
}
globalThis.Promise = require("core-js/es/promise/index.js");

View File

@ -551,13 +551,13 @@ class MessageHandler {
async _deleteStreamController(streamId) {
// Delete the `streamController` only when the start, pull, and cancel
// capabilities have settled, to prevent `TypeError`s.
await Promise.all(
await Promise.allSettled(
[
this.streamControllers[streamId].startCall,
this.streamControllers[streamId].pullCall,
this.streamControllers[streamId].cancelCall,
].map(function(capability) {
return capability && capability.promise.catch(function() {});
return capability && capability.promise;
})
);
delete this.streamControllers[streamId];