diff --git a/lib/internal/util.js b/lib/internal/util.js index 48724374b0eec0..3d63b983a2cbed 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -410,7 +410,8 @@ function promisify(original) { } }); if (isPromise(ReflectApply(original, this, args))) { - process.emitWarning('Calling promisify on a function that returns a Promise is likely a mistake.'); + process.emitWarning('Calling promisify on a function that returns a Promise is likely a mistake.', + 'DeprecationWarning', 'DEP0174'); } }); } diff --git a/test/parallel/test-util-promisify.js b/test/parallel/test-util-promisify.js index 82e7218eabcc46..e2318a4973b972 100644 --- a/test/parallel/test-util-promisify.js +++ b/test/parallel/test-util-promisify.js @@ -16,9 +16,17 @@ const { customPromisifyArgs } = require('internal/util'); process.off('warning', warningHandler); } -common.expectWarning('Warning', 'Calling promisify on a function that returns a Promise is likely a mistake.'); +common.expectWarning( + 'DeprecationWarning', + 'Calling promisify on a function that returns a Promise is likely a mistake.', + 'DEP0174'); promisify(async (callback) => { callback(); })().then(common.mustCall(() => { - common.expectWarning('Warning', 'Calling promisify on a function that returns a Promise is likely a mistake.'); + // We must add the second `expectWarning` call in the `.then` handler, when + // the first warning has already been triggered. + common.expectWarning( + 'DeprecationWarning', + 'Calling promisify on a function that returns a Promise is likely a mistake.', + 'DEP0174'); promisify(async () => {})().then(common.mustNotCall()); }));