From 1bcbc70ea8267ecc9a21570c841c2b5bdcc3fde3 Mon Sep 17 00:00:00 2001 From: Antoine du HAMEL Date: Wed, 20 Nov 2019 19:48:49 +0100 Subject: [PATCH] process: refs --unhandled-rejections documentation in warning message Refs: https://github.com/nodejs/node/issues/20392 PR-URL: https://github.com/nodejs/node/pull/30564 Reviewed-By: Anna Henningsen Reviewed-By: Gus Caplan Reviewed-By: Benjamin Gruenbaum Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- lib/internal/process/promises.js | 3 +++ test/parallel/test-promises-unhandled-proxy-rejections.js | 5 ++++- test/parallel/test-promises-unhandled-symbol-rejections.js | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/internal/process/promises.js b/lib/internal/process/promises.js index 47d58de99611fe..5128b98f5a1e7e 100644 --- a/lib/internal/process/promises.js +++ b/lib/internal/process/promises.js @@ -134,6 +134,9 @@ function emitUnhandledRejectionWarning(uid, reason) { 'Unhandled promise rejection. This error originated either by ' + 'throwing inside of an async function without a catch block, ' + 'or by rejecting a promise which was not handled with .catch(). ' + + 'To terminate the node process on unhandled promise ' + + 'rejection, use the CLI flag `--unhandled-rejections=strict` (see ' + + 'https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). ' + `(rejection id: ${uid})` ); try { diff --git a/test/parallel/test-promises-unhandled-proxy-rejections.js b/test/parallel/test-promises-unhandled-proxy-rejections.js index 659db4d17911ee..31d2ed27ed0205 100644 --- a/test/parallel/test-promises-unhandled-proxy-rejections.js +++ b/test/parallel/test-promises-unhandled-proxy-rejections.js @@ -12,7 +12,10 @@ const expectedPromiseWarning = ['Unhandled promise rejection. ' + 'This error originated either by throwing ' + 'inside of an async function without a catch ' + 'block, or by rejecting a promise which was ' + - 'not handled with .catch(). (rejection id: 1)']; + 'not handled with .catch(). To terminate the ' + + 'node process on unhandled promise rejection, ' + + 'use the CLI flag `--unhandled-rejections=strict` (see ' + + 'https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)']; function throwErr() { throw new Error('Error from proxy'); diff --git a/test/parallel/test-promises-unhandled-symbol-rejections.js b/test/parallel/test-promises-unhandled-symbol-rejections.js index 460acaca57c6d4..3672c8700d6744 100644 --- a/test/parallel/test-promises-unhandled-symbol-rejections.js +++ b/test/parallel/test-promises-unhandled-symbol-rejections.js @@ -13,7 +13,10 @@ const expectedPromiseWarning = ['Unhandled promise rejection. ' + 'This error originated either by throwing ' + 'inside of an async function without a catch ' + 'block, or by rejecting a promise which was ' + - 'not handled with .catch(). (rejection id: 1)']; + 'not handled with .catch(). To terminate the ' + + 'node process on unhandled promise rejection, ' + + 'use the CLI flag `--unhandled-rejections=strict` (see ' + + 'https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)']; common.expectWarning({ DeprecationWarning: expectedDeprecationWarning,