From 9514f5db8d34475b8139184dfea343ef99284145 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Fri, 3 Jun 2016 03:18:01 +0200 Subject: [PATCH] Switch around Promise resolution and completion events to ensure that, when using awaitCompleted, the execution order makes sense --- lib/index.js | 2 +- src/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 87fb70f..de73081 100644 --- a/lib/index.js +++ b/lib/index.js @@ -80,8 +80,8 @@ module.exports = function createTaskQueue(options) { Promise.try(function () { return handlers[type](task.data); }).then(function (result) { - markSuccess(type, task); task.resolve(result); + markSuccess(type, task); }).catch(function (err) { markFailed(type, task); task.reject(err); diff --git a/src/index.js b/src/index.js index 3cf48ee..db45383 100644 --- a/src/index.js +++ b/src/index.js @@ -80,8 +80,8 @@ module.exports = function createTaskQueue(options) { Promise.try(() => { return handlers[type](task.data); }).then((result) => { - markSuccess(type, task); task.resolve(result); + markSuccess(type, task); }).catch((err) => { markFailed(type, task); task.reject(err);