process: runtime deprecate multipleResolves

PR-URL: https://github.com/nodejs/node/pull/41896
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Benjamin Gruenbaum
2022-02-08 18:28:25 +02:00
parent ceaa299958
commit 60b8e79599
3 changed files with 28 additions and 2 deletions

View File

@@ -3075,12 +3075,15 @@ the errors used for value type validation.
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/41896
description: Runtime deprecation.
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/41872
description: Documentation-only deprecation.
-->
Type: Documentation-only
Type: Runtime.
This event was deprecated because it did not work with V8 promise combinators
which diminished its usefulness.

View File

@@ -20,6 +20,8 @@ const {
setPromiseRejectCallback
} = internalBinding('task_queue');
const { deprecate } = require('internal/util');
const {
noSideEffectsToString,
triggerUncaughtException
@@ -124,11 +126,18 @@ function promiseRejectHandler(type, promise, reason) {
}
}
const multipleResolvesDeprecate = deprecate(
() => {},
'The multipleResolves event has been deprecated.',
'DEPXXXX'
);
function resolveError(type, promise, reason) {
// We have to wrap this in a next tick. Otherwise the error could be caught by
// the executed promise.
process.nextTick(() => {
process.emit('multipleResolves', type, promise, reason);
if (process.emit('multipleResolves', type, promise, reason)) {
multipleResolvesDeprecate();
}
});
}

View File

@@ -0,0 +1,14 @@
import { expectWarning, mustCall } from '../common/index.mjs';
expectWarning(
'DeprecationWarning',
'The multipleResolves event has been deprecated.',
'DEPXXXX',
);
process.on('multipleResolves', mustCall());
new Promise((resolve) => {
resolve();
resolve();
});