diff --git a/lib/internal/process/promises.js b/lib/internal/process/promises.js index 7710bfaf5f118f..82f15f9f9df51e 100644 --- a/lib/internal/process/promises.js +++ b/lib/internal/process/promises.js @@ -1,5 +1,7 @@ 'use strict'; +const { safeToString } = process.binding('util'); + const promiseRejectEvent = process._promiseRejectEvent; const hasBeenNotifiedProperty = new WeakMap(); const promiseToGuidProperty = new WeakMap(); @@ -62,7 +64,9 @@ function setupPromises(scheduleMicrotasks) { if (reason instanceof Error) { process.emitWarning(reason.stack, 'UnhandledPromiseRejectionWarning'); } else { - process.emitWarning(reason, 'UnhandledPromiseRejectionWarning'); + process.emitWarning( + safeToString(reason), 'UnhandledPromiseRejectionWarning' + ); } } catch (e) { // ignored