Skip to content

Commit edc6a7a

Browse files
aduh95targos
authored andcommitted
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 4a57d47 commit edc6a7a

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
@@ -1261,6 +1261,9 @@ occurs. One of the following modes can be chosen:
12611261
set, trigger a warning, and set the process exit code to 1.
12621262
* `none`: Silence all warnings.
12631263

1264+
If a rejection happens during the command line entry point's ES module static
1265+
loading phase, it will always raise it as an uncaught exception.
1266+
12641267
### `--use-bundled-ca`, `--use-openssl-ca`
12651268

12661269
<!-- 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)