Skip to content

Commit 60b8e79

Browse files
committed
process: runtime deprecate multipleResolves
PR-URL: #41896 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent ceaa299 commit 60b8e79

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

doc/api/deprecations.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -3075,12 +3075,15 @@ the errors used for value type validation.
30753075

30763076
<!-- YAML
30773077
changes:
3078+
- version: REPLACEME
3079+
pr-url: https://github.com/nodejs/node/pull/41896
3080+
description: Runtime deprecation.
30783081
- version: REPLACEME
30793082
pr-url: https://github.com/nodejs/node/pull/41872
30803083
description: Documentation-only deprecation.
30813084
-->
30823085

3083-
Type: Documentation-only
3086+
Type: Runtime.
30843087

30853088
This event was deprecated because it did not work with V8 promise combinators
30863089
which diminished its usefulness.

lib/internal/process/promises.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const {
2020
setPromiseRejectCallback
2121
} = internalBinding('task_queue');
2222

23+
const { deprecate } = require('internal/util');
24+
2325
const {
2426
noSideEffectsToString,
2527
triggerUncaughtException
@@ -124,11 +126,18 @@ function promiseRejectHandler(type, promise, reason) {
124126
}
125127
}
126128

129+
const multipleResolvesDeprecate = deprecate(
130+
() => {},
131+
'The multipleResolves event has been deprecated.',
132+
'DEPXXXX'
133+
);
127134
function resolveError(type, promise, reason) {
128135
// We have to wrap this in a next tick. Otherwise the error could be caught by
129136
// the executed promise.
130137
process.nextTick(() => {
131-
process.emit('multipleResolves', type, promise, reason);
138+
if (process.emit('multipleResolves', type, promise, reason)) {
139+
multipleResolvesDeprecate();
140+
}
132141
});
133142
}
134143

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { expectWarning, mustCall } from '../common/index.mjs';
2+
3+
expectWarning(
4+
'DeprecationWarning',
5+
'The multipleResolves event has been deprecated.',
6+
'DEPXXXX',
7+
);
8+
9+
process.on('multipleResolves', mustCall());
10+
11+
new Promise((resolve) => {
12+
resolve();
13+
resolve();
14+
});

0 commit comments

Comments
 (0)