From 490cac0d7e9b455de74eb6038e555a60a2fafe13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Geisend=C3=B6rfer?= Date: Mon, 15 Feb 2010 23:54:55 +0100 Subject: [PATCH] Fix Promise.wait() for fired promises Failure introduced in 80ace36e4cb287c36b44c6b986c5e5dea2b1c825 --- src/node.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/node.js b/src/node.js index e31e000d03a..026234bafb9 100644 --- a/src/node.js +++ b/src/node.js @@ -297,6 +297,18 @@ var eventsModule = createInternalModule('events', function (exports) { var ret; var hadError = false; + if (this.hasFired) { + ret = (this._values.length == 1) + ? this._values[0] + : this.values; + + if (this.hasFired == 'success') { + return ret; + } else if (this.hasFired == 'error') { + throw ret; + } + } + self.addCallback(function () { if (arguments.length == 1) { ret = arguments[0];