mirror of https://github.com/lukechilds/node.git
Browse Source
Give better stack traces for `PromiseRejectionHandledWarning` and `UnhandledPromiseRejectionWarning`s. For `PromiseRejectionHandledWarning`, when it is likely that there is an `Error` object generated, it is created early to provide a proper stack trace. For `UnhandledPromiseRejectionWarning`, the stack trace of the underlying error object is used, if possible. Fixes: https://github.com/nodejs/node/issues/9523 PR-URL: https://github.com/nodejs/node/pull/9525 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>v6
Anna Henningsen
8 years ago
3 changed files with 51 additions and 2 deletions
@ -0,0 +1,5 @@ |
|||||
|
// Flags: --trace-warnings
|
||||
|
'use strict'; |
||||
|
require('../common'); |
||||
|
const p = Promise.reject(new Error('This was rejected')); |
||||
|
setImmediate(() => p.catch(() => {})); |
@ -0,0 +1,31 @@ |
|||||
|
(node:*) Error: This was rejected |
||||
|
at * (*test*message*unhandled_promise_trace_warnings.js:*) |
||||
|
at * |
||||
|
at * |
||||
|
at * |
||||
|
at * |
||||
|
at * |
||||
|
at * |
||||
|
at * |
||||
|
at * |
||||
|
at * |
||||
|
(node:*) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. |
||||
|
at * |
||||
|
at * |
||||
|
at * |
||||
|
at * |
||||
|
at * |
||||
|
at * |
||||
|
at * |
||||
|
at * |
||||
|
at * |
||||
|
(node:*) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1) |
||||
|
at getAsynchronousRejectionWarningObject (internal/process/promises.js:*) |
||||
|
at rejectionHandled (internal/process/promises.js:*) |
||||
|
at * |
||||
|
at Promise.then (native) |
||||
|
at Promise.catch (native) |
||||
|
at Immediate.setImmediate (*test*message*unhandled_promise_trace_warnings.js:*) |
||||
|
at * |
||||
|
at * |
||||
|
at * |
Loading…
Reference in new issue