Skip to content

Commit 632fc1f

Browse files
cjihrigtargos
authored andcommitted
doc: make multipleResolves docs less opinionated
The 'multipleResolves' event does not necessarily indicate an error. This commit makes the documentation less opinionated, and includes potential caveats. PR-URL: #28314 Refs: #24321 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 6063ceb commit 632fc1f

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

doc/api/process.md

+6-9
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ not be the same as what is originally sent.
107107
added: v10.12.0
108108
-->
109109

110-
* `type` {string} The error type. One of `'resolve'` or `'reject'`.
110+
* `type` {string} The resolution type. One of `'resolve'` or `'reject'`.
111111
* `promise` {Promise} The promise that resolved or rejected more than once.
112112
* `value` {any} The value with which the promise was either resolved or
113113
rejected after the original resolve.
@@ -119,14 +119,10 @@ The `'multipleResolves'` event is emitted whenever a `Promise` has been either:
119119
* Rejected after resolve.
120120
* Resolved after reject.
121121

122-
This is useful for tracking errors in an application while using the promise
123-
constructor. Otherwise such mistakes are silently swallowed due to being in a
124-
dead zone.
125-
126-
It is recommended to end the process on such errors, since the process could be
127-
in an undefined state. While using the promise constructor make sure that it is
128-
guaranteed to trigger the `resolve()` or `reject()` functions exactly once per
129-
call and never call both functions in the same call.
122+
This is useful for tracking potential errors in an application while using the
123+
`Promise` constructor, as multiple resolutions are silently swallowed. However,
124+
the occurrence of this event does not necessarily indicate an error. For
125+
example, [`Promise.race()`][] can trigger a `'multipleResolves'` event.
130126

131127
```js
132128
process.on('multipleResolves', (type, promise, reason) => {
@@ -2314,6 +2310,7 @@ cases:
23142310
[`process.kill()`]: #process_process_kill_pid_signal
23152311
[`process.setUncaughtExceptionCaptureCallback()`]: process.html#process_process_setuncaughtexceptioncapturecallback_fn
23162312
[`promise.catch()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch
2313+
[`Promise.race()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race
23172314
[`require()`]: globals.html#globals_require
23182315
[`require.main`]: modules.html#modules_accessing_the_main_module
23192316
[`require.resolve()`]: modules.html#modules_require_resolve_request_options

0 commit comments

Comments
 (0)