diff --git a/bower.json b/bower.json index 9d03f1fa6..7f0df5ae5 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "bluebird", - "version": "2.2.0", + "version": "2.2.1", "homepage": "https://github.com/petkaantonov/bluebird", "authors": [ "Petka Antonov " diff --git a/browser/bundle.js b/browser/bundle.js index 92c0116de..26e8df6d3 100644 --- a/browser/bundle.js +++ b/browser/bundle.js @@ -3878,6 +3878,22 @@ CapturedTrace.combine = function CapturedTrace$Combine(current, prev) { return ret; }; +CapturedTrace.protectErrorMessageNewlines = function(stack) { + for (var i = 0; i < stack.length; ++i) { + if (rtraceline.test(stack[i])) { + break; + } + } + + if (i <= 1) return; + + var errorMessageLines = []; + for (var j = 0; j < i; ++j) { + errorMessageLines.push(stack.shift()); + } + stack.unshift(errorMessageLines.join("\u0002\u0000\u0001")); +}; + CapturedTrace.isSupported = function CapturedTrace$IsSupported() { return typeof captureStackTrace === "function"; }; @@ -6021,8 +6037,8 @@ function Promise$_attachExtraTrace(error) { "canAttach(error)"); var promise = this; var stack = error.stack; - stack = typeof stack === "string" - ? stack.split("\n") : []; + stack = typeof stack === "string" ? stack.split("\n") : []; + CapturedTrace.protectErrorMessageNewlines(stack); var headerLineCount = 1; var combinedTraces = 1; while(promise != null && @@ -6038,9 +6054,13 @@ function Promise$_attachExtraTrace(error) { var stackTraceLimit = Error.stackTraceLimit || 10; var max = (stackTraceLimit + headerLineCount) * combinedTraces; var len = stack.length; - if (len > max) { + if (len > max) { stack.length = max; } + + if (len > 0) + stack[0] = stack[0].split("\u0002\u0000\u0001").join("\n"); + if (stack.length <= headerLineCount) { error.stack = "(No stack trace)"; } else { diff --git a/js/browser/bluebird.js b/js/browser/bluebird.js index a0e3955f0..ec656afcc 100644 --- a/js/browser/bluebird.js +++ b/js/browser/bluebird.js @@ -1,5 +1,5 @@ /** - * bluebird build version 2.2.0 + * bluebird build version 2.2.1 * Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, progress, cancel, using, filter, any, each, timers */ /** @@ -539,6 +539,22 @@ CapturedTrace.combine = function CapturedTrace$Combine(current, prev) { return ret; }; +CapturedTrace.protectErrorMessageNewlines = function(stack) { + for (var i = 0; i < stack.length; ++i) { + if (rtraceline.test(stack[i])) { + break; + } + } + + if (i <= 1) return; + + var errorMessageLines = []; + for (var j = 0; j < i; ++j) { + errorMessageLines.push(stack.shift()); + } + stack.unshift(errorMessageLines.join("\u0002\u0000\u0001")); +}; + CapturedTrace.isSupported = function CapturedTrace$IsSupported() { return typeof captureStackTrace === "function"; }; @@ -2614,8 +2630,8 @@ function Promise$_attachExtraTrace(error) { if (debugging) { var promise = this; var stack = error.stack; - stack = typeof stack === "string" - ? stack.split("\n") : []; + stack = typeof stack === "string" ? stack.split("\n") : []; + CapturedTrace.protectErrorMessageNewlines(stack); var headerLineCount = 1; var combinedTraces = 1; while(promise != null && @@ -2631,9 +2647,13 @@ function Promise$_attachExtraTrace(error) { var stackTraceLimit = Error.stackTraceLimit || 10; var max = (stackTraceLimit + headerLineCount) * combinedTraces; var len = stack.length; - if (len > max) { + if (len > max) { stack.length = max; } + + if (len > 0) + stack[0] = stack[0].split("\u0002\u0000\u0001").join("\n"); + if (stack.length <= headerLineCount) { error.stack = "(No stack trace)"; } else { diff --git a/package.json b/package.json index 316cae039..8342f1c1a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bluebird", "description": "Full featured Promises/A+ implementation with exceptionally good performance", - "version": "2.2.0", + "version": "2.2.1", "keywords": [ "promise", "performance",