Merge pull request #10970 from Snuffleupagus/MessageHandler-simplify-finalize

Simplify, and inline, the `finalize` function in the `MessageHandler` class
This commit is contained in:
Tim van der Meij 2019-07-14 14:45:15 +02:00 committed by GitHub
commit 766d076dcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,10 +60,6 @@ function resolveOrReject(capability, data) {
}
}
function finalize(promise) {
return Promise.resolve(promise).catch(() => {});
}
function MessageHandler(sourceName, targetName, comObj) {
this.sourceName = sourceName;
this.targetName = targetName;
@ -326,14 +322,14 @@ MessageHandler.prototype = {
};
let deleteStreamController = () => {
// Delete streamController only when start, pull and
// cancel callbacks are resolved, to avoid "TypeError".
// Delete the `streamController` only when the start, pull, and cancel
// capabilities have settled, to prevent `TypeError`s.
Promise.all([
this.streamControllers[data.streamId].startCall,
this.streamControllers[data.streamId].pullCall,
this.streamControllers[data.streamId].cancelCall
].map(function(capability) {
return capability && finalize(capability.promise);
return capability && capability.promise.catch(function() { });
})).then(() => {
delete this.streamControllers[data.streamId];
});