Skip to content

Commit cd0350f

Browse files
edsadraduh95
authored andcommitted
doc: document REPL DEP0185 throws and uncaught-exception behavior
Two doc-only improvements to `doc/api/repl.md`, both filling gaps left by recent semver-major REPL changes: 1. `repl.REPLServer` is an ES class; calling it without `new` is End-of-Life (DEP0185) and throws a native V8 `TypeError`. The "Class: REPLServer" section now notes this and links to the DEP0185 entry in `doc/api/deprecations.md`. No `Stability: 0` banner is added because the class itself is not deprecated — only the `new`-less invocation is — matching the parallel DEP0184/DEP0195 "classes without `new`" convention. 2. PR #64034 ("repl: use inspector over vm") removed the old "Global uncaught exceptions" subsection because the `domain`-based restrictions it documented no longer exist. A new top-level `### Error handling` section documents the current model (mirroring the `### Error handling` convention in async_hooks/http2/quic), anchored to the existing `Uncaught Error: REPL await` example. Refs: #59495 Refs: #54869 Refs: #54842 Refs: #64034 Signed-off-by: Adrian Estrada <edsadr@gmail.com> PR-URL: #64993 Reviewed-By: Erick Wendel <erick.workspace@gmail.com> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent caf4963 commit cd0350f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

doc/api/repl.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,15 @@ Uncaught SyntaxError: Identifier 'm' has already been declared
276276

277277
[`--no-experimental-repl-await`][] shall disable top-level await in REPL.
278278

279+
### Error handling
280+
281+
By default, uncaught exceptions in the REPL are printed to the output stream
282+
(as with `Uncaught Error: REPL await` above). `uncaughtException` listeners
283+
can be added freely in both standalone and nested REPLs. The `handleError`
284+
option of [`repl.start()`][] can customize this behavior, including
285+
forwarding exceptions to [`'uncaughtException'`][] by returning
286+
`'unhandled'`.
287+
279288
### Reverse-i-search
280289

281290
<!-- YAML
@@ -469,6 +478,9 @@ const firstInstance = repl.start(options);
469478
const secondInstance = new repl.REPLServer(options);
470479
```
471480

481+
Calling `repl.REPLServer()` without the `new` keyword throws a `TypeError`
482+
(see [DEP0185][]).
483+
472484
### Event: `'exit'`
473485

474486
<!-- YAML
@@ -1170,6 +1182,7 @@ avoiding open network interfaces.
11701182

11711183
Original code from <https://gist.github.com/TooTallNate/2053342>.
11721184

1185+
[DEP0185]: deprecations.md#dep0185-instantiating-noderepl-classes-without-new
11731186
[TTY keybindings]: readline.md#tty-keybindings
11741187
[ZSH]: https://en.wikipedia.org/wiki/Z_shell
11751188
[`'uncaughtException'`]: process.md#event-uncaughtexception

0 commit comments

Comments
 (0)