From 3ef5662b624beb225eb4d2b17e270bc850e3c19b Mon Sep 17 00:00:00 2001 From: Antoine du HAMEL Date: Wed, 20 Nov 2019 19:48:49 +0100 Subject: [PATCH 1/3] process: refs --unhandled-rejections documentation in warning message Refs: https://github.com/nodejs/node/issues/20392 --- 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 ab833776070449..4def15afd687a6 100644 --- a/lib/internal/process/promises.js +++ b/lib/internal/process/promises.js @@ -133,6 +133,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(). ' + + 'If you want node process to terminate 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..14707b98f31688 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(). If you want node ' + + 'process to terminate 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..95096404fc57d8 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(). If you want node ' + + 'process to terminate 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, From 025930b860bbba10c69a809b6fd9255645f5d8aa Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 2 Dec 2019 10:33:11 +0100 Subject: [PATCH 2/3] Update lib/internal/process/promises.js Co-Authored-By: James M Snell --- lib/internal/process/promises.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/process/promises.js b/lib/internal/process/promises.js index 4def15afd687a6..dcfbec9475220b 100644 --- a/lib/internal/process/promises.js +++ b/lib/internal/process/promises.js @@ -133,7 +133,7 @@ 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(). ' + - 'If you want node process to terminate on unhandled promise ' + + '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})` From 8dfd99b6f78ec99c339c2bf8ee8a4e7dc89370d0 Mon Sep 17 00:00:00 2001 From: Antoine du HAMEL Date: Mon, 2 Dec 2019 10:37:39 +0100 Subject: [PATCH 3/3] change wording --- test/parallel/test-promises-unhandled-proxy-rejections.js | 6 +++--- test/parallel/test-promises-unhandled-symbol-rejections.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-promises-unhandled-proxy-rejections.js b/test/parallel/test-promises-unhandled-proxy-rejections.js index 14707b98f31688..31d2ed27ed0205 100644 --- a/test/parallel/test-promises-unhandled-proxy-rejections.js +++ b/test/parallel/test-promises-unhandled-proxy-rejections.js @@ -12,9 +12,9 @@ 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(). If you want node ' + - 'process to terminate on unhandled promise ' + - 'rejection, use the CLI flag `--unhandled-rejections=strict` (see ' + + '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() { diff --git a/test/parallel/test-promises-unhandled-symbol-rejections.js b/test/parallel/test-promises-unhandled-symbol-rejections.js index 95096404fc57d8..3672c8700d6744 100644 --- a/test/parallel/test-promises-unhandled-symbol-rejections.js +++ b/test/parallel/test-promises-unhandled-symbol-rejections.js @@ -13,9 +13,9 @@ 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(). If you want node ' + - 'process to terminate on unhandled promise ' + - 'rejection, use the CLI flag `--unhandled-rejections=strict` (see ' + + '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({