From 9afb22615fd9ad8536c87598c7ff7fb2879d198e Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Mon, 20 Apr 2026 08:41:06 -0700 Subject: [PATCH 1/2] process: move multipleResolves event to EOL Co-authored-by: James M Snell --- doc/api/deprecations.md | 6 +- doc/api/process.md | 90 ------------------- lib/internal/process/promises.js | 23 +---- test/parallel/test-events-once.js | 1 - test/parallel/test-promise-swallowed-event.js | 58 ------------ .../test-timers-immediate-promisified.js | 2 - .../test-timers-interval-promisified.js | 2 - .../test-timers-timeout-promisified.js | 2 - test/parallel/test-warn-multipleResolves.mjs | 14 --- 9 files changed, 7 insertions(+), 191 deletions(-) delete mode 100644 test/parallel/test-promise-swallowed-event.js delete mode 100644 test/parallel/test-warn-multipleResolves.mjs diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 5243fa0fb2b621..6ae949043ff6bf 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -3099,10 +3099,10 @@ changes: description: Documentation-only deprecation. --> -Type: Runtime. +Type: End-of-Life. -This event was deprecated because it did not work with V8 promise combinators -which diminished its usefulness. +This event was deprecated and removed because it did not work with V8 promise +combinators which diminished its usefulness. ### DEP0161: `process._getActiveRequests()` and `process._getActiveHandles()` diff --git a/doc/api/process.md b/doc/api/process.md index b38ef46189f72e..f2f8eb6febb2a1 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -176,95 +176,6 @@ process, the `message` argument can contain data that JSON is not able to represent. See [Advanced serialization for `child_process`][] for more details. -### Event: `'multipleResolves'` - - - -> Stability: 0 - Deprecated - -* `type` {string} The resolution type. One of `'resolve'` or `'reject'`. -* `promise` {Promise} The promise that resolved or rejected more than once. -* `value` {any} The value with which the promise was either resolved or - rejected after the original resolve. - -The `'multipleResolves'` event is emitted whenever a `Promise` has been either: - -* Resolved more than once. -* Rejected more than once. -* Rejected after resolve. -* Resolved after reject. - -This is useful for tracking potential errors in an application while using the -`Promise` constructor, as multiple resolutions are silently swallowed. However, -the occurrence of this event does not necessarily indicate an error. For -example, [`Promise.race()`][] can trigger a `'multipleResolves'` event. - -Because of the unreliability of the event in cases like the -[`Promise.race()`][] example above it has been deprecated. - -```mjs -import process from 'node:process'; - -process.on('multipleResolves', (type, promise, reason) => { - console.error(type, promise, reason); - setImmediate(() => process.exit(1)); -}); - -async function main() { - try { - return await new Promise((resolve, reject) => { - resolve('First call'); - resolve('Swallowed resolve'); - reject(new Error('Swallowed reject')); - }); - } catch { - throw new Error('Failed'); - } -} - -main().then(console.log); -// resolve: Promise { 'First call' } 'Swallowed resolve' -// reject: Promise { 'First call' } Error: Swallowed reject -// at Promise (*) -// at new Promise () -// at main (*) -// First call -``` - -```cjs -const process = require('node:process'); - -process.on('multipleResolves', (type, promise, reason) => { - console.error(type, promise, reason); - setImmediate(() => process.exit(1)); -}); - -async function main() { - try { - return await new Promise((resolve, reject) => { - resolve('First call'); - resolve('Swallowed resolve'); - reject(new Error('Swallowed reject')); - }); - } catch { - throw new Error('Failed'); - } -} - -main().then(console.log); -// resolve: Promise { 'First call' } 'Swallowed resolve' -// reject: Promise { 'First call' } Error: Swallowed reject -// at Promise (*) -// at new Promise () -// at main (*) -// First call -``` - ### Event: `'rejectionHandled'`