From f85b9d9fa82094f3fa0cac3fd1baceb438eab057 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 12 Mar 2026 17:35:31 +0100 Subject: [PATCH] repl: add customizable error handling Whether or not an exception should be handled when it was thrown in the REPL's context but the REPL is already closed is something that will depend on the details of the specific REPL instance's use case. Adding this option lets the REPL's creator control the details of this behavior. This resolves a TODO recently added in bd3cba5633e8a36. PR-URL: https://github.com/nodejs/node/pull/62188 Reviewed-By: Colin Ihrig Reviewed-By: Chemi Atlow --- doc/api/repl.md | 14 ++++ lib/repl.js | 25 ++++-- test/parallel/test-repl-user-error-handler.js | 84 +++++++++++++++++++ 3 files changed, 116 insertions(+), 7 deletions(-) create mode 100644 test/parallel/test-repl-user-error-handler.js diff --git a/doc/api/repl.md b/doc/api/repl.md index 0ebd5ca4e6f..c26b2a56dc8 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -709,6 +709,9 @@ npx codemod@latest @nodejs/repl-builtin-modules