Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

process: runtime deprecate multipleResolves #41896

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 10 additions & 1 deletion lib/internal/process/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const {
setPromiseRejectCallback
} = internalBinding('task_queue');

const { deprecate } = require('internal/util');

const {
noSideEffectsToString,
triggerUncaughtException
Expand Down Expand Up @@ -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();
}
});
}

Expand Down
14 changes: 14 additions & 0 deletions test/parallel/test-warn-multipleResolves.mjs
Original file line number Diff line number Diff line change
@@ -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();
});