fix(js_repl): surface uncaught kernel errors and reset cleanly#12636
Merged
fix(js_repl): surface uncaught kernel errors and reset cleanly#12636
Conversation
aaronl-openai
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improve
js_replbehavior when the Node kernel hits a process-level failure (for example, an uncaught exception or unhandled Promise rejection).Instead of only surfacing a generic
js_repl kernel exited unexpectedlyafter stdout EOF,js_replnow returns a clearer exec error for the active request, then resets the kernel cleanly.Why
Some sandbox-denied operations can trigger Node errors that become process-level failures (for example, an unhandled EventEmitter
'error'event). In that case:This change improves that failure mode without monkeypatching Node APIs.
Changes
Kernel-side (
js_replNode process)uncaughtExceptionunhandledRejectionexec_resulterror for the active exec'error'events)Host-side (
JsReplManager)js_replexec start a fresh kernel instead of hitting a stale broken-pipe path.Tests
Impact
Validation
cargo test -p codex-core --lib tools::js_repl::tests::js_repl_uncaught_exception_returns_exec_error_and_recovers -- --exactcargo test -p codex-core --lib tools::js_repl::tests::js_repl_forced_kernel_exit_recovers_on_next_exec -- --exactjust fmt