mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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:
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
14
test/parallel/test-warn-multipleResolves.mjs
Normal file
14
test/parallel/test-warn-multipleResolves.mjs
Normal 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();
|
||||
});
|
||||
Reference in New Issue
Block a user