Skip to content

Commit 52a988b

Browse files
aduh95danielleadams
authored andcommittedFeb 1, 2022
doc: clarify uncaughtException origin for ESM
Fixes: #41328 PR-URL: #41339 Reviewed-By: Geoffrey Booth <[email protected]> Reviewed-By: Bradley Farias <[email protected]>
1 parent 62450d3 commit 52a988b

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed
 

‎doc/api/cli.md

+3
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,9 @@ occurs. One of the following modes can be chosen:
12321232
set, trigger a warning, and set the process exit code to 1.
12331233
* `none`: Silence all warnings.
12341234

1235+
If a rejection happens during the command line entry point's ES module static
1236+
loading phase, it will always raise it as an uncaught exception.
1237+
12351238
### `--use-bundled-ca`, `--use-openssl-ca`
12361239

12371240
<!-- YAML

‎doc/api/process.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,11 @@ changes:
335335
* `err` {Error} The uncaught exception.
336336
* `origin` {string} Indicates if the exception originates from an unhandled
337337
rejection or from an synchronous error. Can either be `'uncaughtException'` or
338-
`'unhandledRejection'`. The latter is only used in conjunction with the
339-
[`--unhandled-rejections`][] flag set to `strict` or `throw` and
340-
an unhandled rejection.
338+
`'unhandledRejection'`. The latter is used when in an exception happens in a
339+
`Promise` based async context (or if a `Promise` is rejected) and
340+
[`--unhandled-rejections`][] flag set to `strict` or `throw` (which is the
341+
default) and the rejection is not handled, or when a rejection happens during
342+
the command line entry point's ES module static loading phase.
341343

342344
The `'uncaughtException'` event is emitted when an uncaught JavaScript
343345
exception bubbles all the way back to the event loop. By default, Node.js
@@ -431,9 +433,11 @@ added:
431433
* `err` {Error} The uncaught exception.
432434
* `origin` {string} Indicates if the exception originates from an unhandled
433435
rejection or from synchronous errors. Can either be `'uncaughtException'` or
434-
`'unhandledRejection'`. The latter is only used in conjunction with the
435-
[`--unhandled-rejections`][] flag set to `strict` or `throw` and
436-
an unhandled rejection.
436+
`'unhandledRejection'`. The latter is used when in an exception happens in a
437+
`Promise` based async context (or if a `Promise` is rejected) and
438+
[`--unhandled-rejections`][] flag set to `strict` or `throw` (which is the
439+
default) and the rejection is not handled, or when a rejection happens during
440+
the command line entry point's ES module static loading phase.
437441

438442
The `'uncaughtExceptionMonitor'` event is emitted before an
439443
`'uncaughtException'` event is emitted or a hook installed via

0 commit comments

Comments
 (0)
Please sign in to comment.