From 9b416eafaa739e4d295bd65b36f8d6cac14e8031 Mon Sep 17 00:00:00 2001 From: Mariusz Nowak Date: Mon, 13 Aug 2018 13:14:06 +0200 Subject: [PATCH] fix: ensure to not force unhandled rejections --- ext/promise.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/promise.js b/ext/promise.js index 27890df..4b7163c 100644 --- a/ext/promise.js +++ b/ext/promise.js @@ -66,7 +66,9 @@ require("../lib/registered-extensions").promise = function (mode, conf) { if (resolvedMode === "then") { var nextTickFailure = function () { nextTick(onFailure); }; - promise.then(function (result) { + // Eventual finally needs to be attached to non rejected promise + // (so we not force propagation of unhandled rejection) + promise = promise.then(function (result) { nextTick(onSuccess.bind(this, result)); }, nextTickFailure); // If `finally` is a function we attach to it to remove cancelled promises.