diff --git a/monitor/aggregator.js b/monitor/aggregator.js index bad270c9..34c5430e 100644 --- a/monitor/aggregator.js +++ b/monitor/aggregator.js @@ -27,6 +27,8 @@ define(function() { } this.key = nextKey++; + promises[this.key] = this; + this.parent = parent; this.timestamp = +(new Date()); this.createdAt = stackHolder; @@ -34,8 +36,6 @@ define(function() { Monitor.prototype = { observed: function () { - this._observed = true; - if(this.key in promises) { delete promises[this.key]; report(); @@ -45,27 +45,26 @@ define(function() { }, fulfilled: function () { if(this.key in promises) { + delete promises[this.key]; report(); } }, rejected: function (reason) { var stackHolder; - if(this._observed) { - return; - } + if(this.key in promises) { - promises[this.key] = this; + try { + throw new Error(reason && reason.message || reason); + } catch (e) { + stackHolder = e; + } - try { - throw new Error(reason && reason.message || reason); - } catch (e) { - stackHolder = e; - } + this.reason = reason; + this.rejectedAt = stackHolder; + report(); - this.reason = reason; - this.rejectedAt = stackHolder; - report(); + } } }; diff --git a/monitor/logger/split.js b/monitor/both.js similarity index 60% rename from monitor/logger/split.js rename to monitor/both.js index 27d54a56..2c425915 100644 --- a/monitor/logger/split.js +++ b/monitor/both.js @@ -12,14 +12,15 @@ define(function() { /** - * Logger that simply forwards to two other loggers - * @param {function} log1 first logger to forward to - * @param {function} log2 second logger to forward to + * Function that forwards its arg to 2 other functions + * @param {function} f1 first function to which to forward + * @param {function} f2 second function to which to forward + * @return {function} */ - return function(log1, log2) { - return function(rejections) { - log1(rejections); - log2(rejections); + return function(f1, f2) { + return function(x) { + f1(x); + f2(x); }; }; diff --git a/test/monitor/index.html b/test/monitor/index.html index ccd9aeaf..e04d5bdf 100644 --- a/test/monitor/index.html +++ b/test/monitor/index.html @@ -12,7 +12,7 @@ preloads: ['when/monitor/console'] }); - curl(['./developer-error']); + curl(['./unhandled-forever']);