| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4d5ee24 commit a3dfca9
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3334,6 +3334,9 @@ the errors used for value type validation. | |||
| 3334 | 3334 | ||
| 3335 | 3335 | <!-- YAML | |
| 3336 | 3336 | changes: | |
| 3337 | + - version: REPLACEME | ||
| 3338 | + pr-url: https://github.com/nodejs/node/pull/58707 | ||
| 3339 | + description: End-of-Life. | ||
| 3337 | 3340 | - version: v18.0.0 | |
| 3338 | 3341 | pr-url: https://github.com/nodejs/node/pull/41896 | |
| 3339 | 3342 | description: Runtime deprecation. | |
@@ -3344,10 +3347,10 @@ changes: | |||
| 3344 | 3347 | description: Documentation-only deprecation. | |
| 3345 | 3348 | --> | |
| 3346 | 3349 | ||
| 3347 | - Type: Runtime | ||
| 3350 | + Type: End-of-Life | ||
| 3348 | 3351 | ||
| 3349 | - This event was deprecated because it did not work with V8 promise combinators | ||
| 3350 | - which diminished its usefulness. | ||
| 3352 | + This event was deprecated and removed because it did not work with V8 promise | ||
| 3353 | + combinators which diminished its usefulness. | ||
| 3351 | 3354 | ||
| 3352 | 3355 | ### DEP0161: `process._getActiveRequests()` and `process._getActiveHandles()` | |
| 3353 | 3356 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -176,95 +176,6 @@ process, the `message` argument can contain data that JSON is not able | |||
| 176 | 176 | to represent. | |
| 177 | 177 | See [Advanced serialization for `child_process`][] for more details. | |
| 178 | 178 | ||
| 179 | - ### Event: `'multipleResolves'` | ||
| 180 | - | ||
| 181 | - <!-- YAML | ||
| 182 | - added: v10.12.0 | ||
| 183 | - deprecated: | ||
| 184 | - - v17.6.0 | ||
| 185 | - - v16.15.0 | ||
| 186 | - --> | ||
| 187 | - | ||
| 188 | - > Stability: 0 - Deprecated | ||
| 189 | - | ||
| 190 | - * `type` {string} The resolution type. One of `'resolve'` or `'reject'`. | ||
| 191 | - * `promise` {Promise} The promise that resolved or rejected more than once. | ||
| 192 | - * `value` {any} The value with which the promise was either resolved or | ||
| 193 | - rejected after the original resolve. | ||
| 194 | - | ||
| 195 | - The `'multipleResolves'` event is emitted whenever a `Promise` has been either: | ||
| 196 | - | ||
| 197 | - * Resolved more than once. | ||
| 198 | - * Rejected more than once. | ||
| 199 | - * Rejected after resolve. | ||
| 200 | - * Resolved after reject. | ||
| 201 | - | ||
| 202 | - This is useful for tracking potential errors in an application while using the | ||
| 203 | - `Promise` constructor, as multiple resolutions are silently swallowed. However, | ||
| 204 | - the occurrence of this event does not necessarily indicate an error. For | ||
| 205 | - example, [`Promise.race()`][] can trigger a `'multipleResolves'` event. | ||
| 206 | - | ||
| 207 | - Because of the unreliability of the event in cases like the | ||
| 208 | - [`Promise.race()`][] example above it has been deprecated. | ||
| 209 | - | ||
| 210 | - ```mjs | ||
| 211 | - import process from 'node:process'; | ||
| 212 | - | ||
| 213 | - process.on('multipleResolves', (type, promise, reason) => { | ||
| 214 | - console.error(type, promise, reason); | ||
| 215 | - setImmediate(() => process.exit(1)); | ||
| 216 | - }); | ||
| 217 | - | ||
| 218 | - async function main() { | ||
| 219 | - try { | ||
| 220 | - return await new Promise((resolve, reject) => { | ||
| 221 | - resolve('First call'); | ||
| 222 | - resolve('Swallowed resolve'); | ||
| 223 | - reject(new Error('Swallowed reject')); | ||
| 224 | - }); | ||
| 225 | - } catch { | ||
| 226 | - throw new Error('Failed'); | ||
| 227 | - } | ||
| 228 | - } | ||
| 229 | - | ||
| 230 | - main().then(console.log); | ||
| 231 | - // resolve: Promise { 'First call' } 'Swallowed resolve' | ||
| 232 | - // reject: Promise { 'First call' } Error: Swallowed reject | ||
| 233 | - // at Promise (*) | ||
| 234 | - // at new Promise (<anonymous>) | ||
| 235 | - // at main (*) | ||
| 236 | - // First call | ||
| 237 | - ``` | ||
| 238 | - | ||
| 239 | - ```cjs | ||
| 240 | - const process = require('node:process'); | ||
| 241 | - | ||
| 242 | - process.on('multipleResolves', (type, promise, reason) => { | ||
| 243 | - console.error(type, promise, reason); | ||
| 244 | - setImmediate(() => process.exit(1)); | ||
| 245 | - }); | ||
| 246 | - | ||
| 247 | - async function main() { | ||
| 248 | - try { | ||
| 249 | - return await new Promise((resolve, reject) => { | ||
| 250 | - resolve('First call'); | ||
| 251 | - resolve('Swallowed resolve'); | ||
| 252 | - reject(new Error('Swallowed reject')); | ||
| 253 | - }); | ||
| 254 | - } catch { | ||
| 255 | - throw new Error('Failed'); | ||
| 256 | - } | ||
| 257 | - } | ||
| 258 | - | ||
| 259 | - main().then(console.log); | ||
| 260 | - // resolve: Promise { 'First call' } 'Swallowed resolve' | ||
| 261 | - // reject: Promise { 'First call' } Error: Swallowed reject | ||
| 262 | - // at Promise (*) | ||
| 263 | - // at new Promise (<anonymous>) | ||
| 264 | - // at main (*) | ||
| 265 | - // First call | ||
| 266 | - ``` | ||
| 267 | - | ||
| 268 | 179 | ### Event: `'rejectionHandled'` | |
| 269 | 180 | ||
| 270 | 181 | <!-- YAML | |
@@ -4603,7 +4514,6 @@ cases: | |||
| 4603 | 4514 | [`Error`]: errors.md#class-error | |
| 4604 | 4515 | [`EventEmitter`]: events.md#class-eventemitter | |
| 4605 | 4516 | [`NODE_OPTIONS`]: cli.md#node_optionsoptions | |
| 4606 | - [`Promise.race()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race | ||
| 4607 | 4517 | [`Worker`]: worker_threads.md#class-worker | |
| 4608 | 4518 | [`Worker` constructor]: worker_threads.md#new-workerfilename-options | |
| 4609 | 4519 | [`console.error()`]: console.md#consoleerrordata-args | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,8 +20,6 @@ const { | |||
| 20 | 20 | setPromiseRejectCallback, | |
| 21 | 21 | } = internalBinding('task_queue'); | |
| 22 | 22 | ||
| 23 | - const { deprecate } = require('internal/util'); | ||
| 24 | - | ||
| 25 | 23 | const { | |
| 26 | 24 | noSideEffectsToString, | |
| 27 | 25 | triggerUncaughtException, | |
@@ -43,27 +41,6 @@ const AsyncContextFrame = require('internal/async_context_frame'); | |||
| 43 | 41 | // *Must* match Environment::TickInfo::Fields in src/env.h. | |
| 44 | 42 | const kHasRejectionToWarn = 1; | |
| 45 | 43 | ||
| 46 | - // By default true because in cases where process is not a global | ||
| 47 | - // it is not possible to determine if the user has added a listener | ||
| 48 | - // to the process object. | ||
| 49 | - let hasMultipleResolvesListener = true; | ||
| 50 | - | ||
| 51 | - if (process.on) { | ||
| 52 | - hasMultipleResolvesListener = process.listenerCount('multipleResolves') !== 0; | ||
| 53 | - | ||
| 54 | - process.on('newListener', (eventName) => { | ||
| 55 | - if (eventName === 'multipleResolves') { | ||
| 56 | - hasMultipleResolvesListener = true; | ||
| 57 | - } | ||
| 58 | - }); | ||
| 59 | - | ||
| 60 | - process.on('removeListener', (eventName) => { | ||
| 61 | - if (eventName === 'multipleResolves') { | ||
| 62 | - hasMultipleResolvesListener = process.listenerCount('multipleResolves') !== 0; | ||
| 63 | - } | ||
| 64 | - }); | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | 44 | /** | |
| 68 | 45 | * Errors & Warnings | |
| 69 | 46 | */ | |
@@ -192,55 +169,16 @@ function promiseRejectHandler(type, promise, reason) { | |||
| 192 | 169 | handledRejection(promise); | |
| 193 | 170 | break; | |
| 194 | 171 | case kPromiseRejectAfterResolved: // 2 | |
| 195 | - if (hasMultipleResolvesListener) { | ||
| 196 | - resolveErrorReject(promise, reason); | ||
| 197 | - } | ||
| 172 | + // Do nothing in this case. Previous we would emit a multipleResolves | ||
| 173 | + // event but that was deprecated then later removed. | ||
| 198 | 174 | break; | |
| 199 | 175 | case kPromiseResolveAfterResolved: // 3 | |
| 200 | - if (hasMultipleResolvesListener) { | ||
| 201 | - resolveErrorResolve(promise, reason); | ||
| 202 | - } | ||
| 176 | + // Do nothing in this case. Previous we would emit a multipleResolves | ||
| 177 | + // event but that was deprecated then later removed. | ||
| 203 | 178 | break; | |
| 204 | 179 | } | |
| 205 | 180 | } | |
| 206 | 181 | ||
| 207 | - const multipleResolvesDeprecate = deprecate( | ||
| 208 | - () => {}, | ||
| 209 | - 'The multipleResolves event has been deprecated.', | ||
| 210 | - 'DEP0160', | ||
| 211 | - ); | ||
| 212 | - | ||
| 213 | - /** | ||
| 214 | - * @param {Promise} promise | ||
| 215 | - * @param {Error} reason | ||
| 216 | - */ | ||
| 217 | - function resolveErrorResolve(promise, reason) { | ||
| 218 | - // We have to wrap this in a next tick. Otherwise the error could be caught by | ||
| 219 | - // the executed promise. | ||
| 220 | - process.nextTick(() => { | ||
| 221 | - // Emit the multipleResolves event. | ||
| 222 | - // This is a deprecated event, so we have to check if it's being listened to. | ||
| 223 | - if (process.emit('multipleResolves', 'resolve', promise, reason)) { | ||
| 224 | - // If the event is being listened to, emit a deprecation warning. | ||
| 225 | - multipleResolvesDeprecate(); | ||
| 226 | - } | ||
| 227 | - }); | ||
| 228 | - } | ||
| 229 | - | ||
| 230 | - /** | ||
| 231 | - * @param {Promise} promise | ||
| 232 | - * @param {Error} reason | ||
| 233 | - */ | ||
| 234 | - function resolveErrorReject(promise, reason) { | ||
| 235 | - // We have to wrap this in a next tick. Otherwise the error could be caught by | ||
| 236 | - // the executed promise. | ||
| 237 | - process.nextTick(() => { | ||
| 238 | - if (process.emit('multipleResolves', 'reject', promise, reason)) { | ||
| 239 | - multipleResolvesDeprecate(); | ||
| 240 | - } | ||
| 241 | - }); | ||
| 242 | - } | ||
| 243 | - | ||
| 244 | 182 | /** | |
| 245 | 183 | * @param {Promise} promise | |
| 246 | 184 | * @param {PromiseInfo} promiseInfo | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -104,7 +104,6 @@ async function stopListeningAfterCatchingError() { | |||
| 104 | 104 | } catch (_e) { | |
| 105 | 105 | err = _e; | |
| 106 | 106 | } | |
| 107 | - process.removeAllListeners('multipleResolves'); | ||
| 108 | 107 | strictEqual(err, expected); | |
| 109 | 108 | strictEqual(ee.listenerCount('error'), 0); | |
| 110 | 109 | strictEqual(ee.listenerCount('myevent'), 0); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,8 +14,6 @@ const setPromiseImmediate = promisify(timers.setImmediate); | |||
| 14 | 14 | ||
| 15 | 15 | assert.strictEqual(setPromiseImmediate, timerPromises.setImmediate); | |
| 16 | 16 | ||
| 17 | - process.on('multipleResolves', common.mustNotCall()); | ||
| 18 | - | ||
| 19 | 17 | { | |
| 20 | 18 | const promise = setPromiseImmediate(); | |
| 21 | 19 | promise.then(common.mustCall((value) => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,8 +14,6 @@ const setPromiseTimeout = promisify(timers.setTimeout); | |||
| 14 | 14 | ||
| 15 | 15 | const { setInterval } = timerPromises; | |
| 16 | 16 | ||
| 17 | - process.on('multipleResolves', common.mustNotCall()); | ||
| 18 | - | ||
| 19 | 17 | { | |
| 20 | 18 | const iterable = setInterval(1, undefined); | |
| 21 | 19 | const iterator = iterable[Symbol.asyncIterator](); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,8 +14,6 @@ const setPromiseTimeout = promisify(timers.setTimeout); | |||
| 14 | 14 | ||
| 15 | 15 | assert.strictEqual(setPromiseTimeout, timerPromises.setTimeout); | |
| 16 | 16 | ||
| 17 | - process.on('multipleResolves', common.mustNotCall()); | ||
| 18 | - | ||
| 19 | 17 | { | |
| 20 | 18 | const promise = setPromiseTimeout(1); | |
| 21 | 19 | promise.then(common.mustCall((value) => { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments