diff --git a/lib/internal/process/promises.js b/lib/internal/process/promises.js index 1ba4aa47f575bf..b4a4582c3095a7 100644 --- a/lib/internal/process/promises.js +++ b/lib/internal/process/promises.js @@ -14,6 +14,8 @@ function getAsynchronousRejectionWarningObject(uid) { } function setupPromises(scheduleMicrotasks) { + let deprecationWarned = false; + process._setupPromises(function(event, promise, reason) { if (event === promiseRejectEvent.unhandled) unhandledRejection(promise, reason); @@ -73,7 +75,7 @@ function setupPromises(scheduleMicrotasks) { 'DeprecationWarning', 'DEP0018'); } } - var deprecationWarned = false; + function emitPendingUnhandledRejections() { let hadListeners = false; while (pendingUnhandledRejections.length > 0) {