From 370787962b65b0b3ba7bf0152e3d40de49e51e23 Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Sun, 27 Jan 2019 16:01:16 -0600 Subject: [PATCH 1/2] process: remove unhandled rejection deprecation warning --- doc/api/deprecations.md | 5 ++++- lib/internal/process/promises.js | 13 ------------- test/message/unhandled_promise_trace_warnings.out | 9 --------- .../test-promises-unhandled-proxy-rejections.js | 6 ------ .../test-promises-unhandled-symbol-rejections.js | 8 +------- .../test-promises-warning-on-unhandled-rejection.js | 10 +++------- 6 files changed, 8 insertions(+), 43 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index ecaea8f4d9f7ae..443e542a778720 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -430,9 +430,12 @@ changes: - version: v7.0.0 pr-url: https://github.com/nodejs/node/pull/8217 description: Runtime deprecation. + - version: REPLACEME + pr-url: REPLACEME + descripion: Deprecation revoked --> -Type: Runtime +Type: Deprecation revoked 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 diff --git a/lib/internal/process/promises.js b/lib/internal/process/promises.js index f3e118e2ce7509..d3cc50937637a6 100644 --- a/lib/internal/process/promises.js +++ b/lib/internal/process/promises.js @@ -103,19 +103,6 @@ function emitWarning(uid, reason) { } catch {} process.emitWarning(warning); - emitDeprecationWarning(); -} - -let deprecationWarned = false; -function emitDeprecationWarning() { - if (!deprecationWarned) { - deprecationWarned = true; - process.emitWarning( - '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.', - 'DeprecationWarning', 'DEP0018'); - } } // If this method returns true, at least one more tick need to be diff --git a/test/message/unhandled_promise_trace_warnings.out b/test/message/unhandled_promise_trace_warnings.out index 1f88a136a9aa13..cdab855a5d7907 100644 --- a/test/message/unhandled_promise_trace_warnings.out +++ b/test/message/unhandled_promise_trace_warnings.out @@ -25,15 +25,6 @@ at * at * at * -(node:*) [DEP0018] 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 * (node:*) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1) at handledRejection (internal/process/promises.js:*) at promiseRejectHandler (internal/process/promises.js:*) diff --git a/test/parallel/test-promises-unhandled-proxy-rejections.js b/test/parallel/test-promises-unhandled-proxy-rejections.js index b3cf5719cb9ab0..687754abd07b2d 100644 --- a/test/parallel/test-promises-unhandled-proxy-rejections.js +++ b/test/parallel/test-promises-unhandled-proxy-rejections.js @@ -3,11 +3,6 @@ const common = require('../common'); common.disableCrashOnUnhandledRejection(); -const expectedDeprecationWarning = ['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.', 'DEP0018']; const expectedPromiseWarning = ['Unhandled promise rejection. ' + 'This error originated either by throwing ' + 'inside of an async function without a catch ' + @@ -35,7 +30,6 @@ const thorny = new Proxy({}, { }); common.expectWarning({ - DeprecationWarning: expectedDeprecationWarning, UnhandledPromiseRejectionWarning: expectedPromiseWarning, }); diff --git a/test/parallel/test-promises-unhandled-symbol-rejections.js b/test/parallel/test-promises-unhandled-symbol-rejections.js index d777a13e62e984..94291bb598ce71 100644 --- a/test/parallel/test-promises-unhandled-symbol-rejections.js +++ b/test/parallel/test-promises-unhandled-symbol-rejections.js @@ -4,11 +4,6 @@ const common = require('../common'); common.disableCrashOnUnhandledRejection(); const expectedValueWarning = ['Symbol()']; -const expectedDeprecationWarning = ['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.', 'DEP0018']; const expectedPromiseWarning = ['Unhandled promise rejection. ' + 'This error originated either by throwing ' + 'inside of an async function without a catch ' + @@ -16,10 +11,9 @@ const expectedPromiseWarning = ['Unhandled promise rejection. ' + 'not handled with .catch(). (rejection id: 1)']; common.expectWarning({ - DeprecationWarning: expectedDeprecationWarning, UnhandledPromiseRejectionWarning: [ expectedValueWarning, - expectedPromiseWarning + expectedPromiseWarning, ], }); diff --git a/test/parallel/test-promises-warning-on-unhandled-rejection.js b/test/parallel/test-promises-warning-on-unhandled-rejection.js index ba420157e72bbd..f16afc8678f122 100644 --- a/test/parallel/test-promises-warning-on-unhandled-rejection.js +++ b/test/parallel/test-promises-warning-on-unhandled-rejection.js @@ -27,14 +27,10 @@ process.on('warning', common.mustCall((warning) => { ); break; case 2: - // One time deprecation warning, first unhandled rejection - assert.strictEqual(warning.name, 'DeprecationWarning'); - break; - case 3: // Number rejection error displayed. Note it's been stringified assert.strictEqual(warning.message, '42'); break; - case 4: + case 3: // Unhandled rejection warning (won't be handled next tick) assert.strictEqual(warning.name, 'UnhandledPromiseRejectionWarning'); assert( @@ -43,13 +39,13 @@ process.on('warning', common.mustCall((warning) => { 'but did not. Had "' + warning.message + '" instead.' ); break; - case 5: + case 4: // Rejection handled asynchronously. assert.strictEqual(warning.name, 'PromiseRejectionHandledWarning'); assert(/Promise rejection was handled asynchronously/ .test(warning.message)); } -}, 6)); +}, 5)); const p = Promise.reject('This was rejected'); // Reject with a string setImmediate(common.mustCall(() => p.catch(() => { }))); From e48d4a720c95b0b8498ef5e55352effc298cf99d Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Fri, 22 Feb 2019 11:53:54 -0600 Subject: [PATCH 2/2] Update unhandled_promise_trace_warnings.out --- test/message/unhandled_promise_trace_warnings.out | 1 - 1 file changed, 1 deletion(-) diff --git a/test/message/unhandled_promise_trace_warnings.out b/test/message/unhandled_promise_trace_warnings.out index f2226f6c0059e1..5cb92f8f61b4c7 100644 --- a/test/message/unhandled_promise_trace_warnings.out +++ b/test/message/unhandled_promise_trace_warnings.out @@ -22,7 +22,6 @@ at * at * at * - at * (node:*) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1) at handledRejection (internal/process/promises.js:*) at promiseRejectHandler (internal/process/promises.js:*)