From 61cdd06c68c967633d36fcb439f400929c2bcb42 Mon Sep 17 00:00:00 2001 From: Jehy Date: Tue, 2 Oct 2018 14:19:29 +0300 Subject: [PATCH] add stack trace for warnings https://github.com/petkaantonov/bluebird/issues/1552 --- src/promise.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/promise.js b/src/promise.js index 10dc52a40..87c3e2b02 100644 --- a/src/promise.js +++ b/src/promise.js @@ -121,6 +121,7 @@ Promise.prototype.then = function (didFulfill, didReject) { if (arguments.length > 1) { msg += ", " + util.classString(didReject); } + msg += new Error().stack; this._warn(msg); } return this._then(didFulfill, didReject, undefined, undefined, undefined); @@ -158,7 +159,8 @@ Promise.prototype.toJSON = function () { Promise.prototype.all = function () { if (arguments.length > 0) { - this._warn(".all() was passed arguments but it does not take any"); + this._warn(".all() was passed arguments but it does not take any " + + new Error().stack); } return new PromiseArray(this).promise(); }; @@ -498,6 +500,7 @@ function(reason, synchronous, ignoreNonErrorWarnings) { if (!hasStack && !ignoreNonErrorWarnings && debug.warnings()) { var message = "a promise was rejected with a non-error: " + util.classString(reason); + message += new Error().stack; this._warn(message, true); } this._attachExtraTrace(trace, synchronous ? hasStack : false);