Install crash handlers so a detached throw terminates the process - #341
Merged
Conversation
TheGreatAxios
force-pushed
the
cl-5565-crash-handlers
branch
2 times, most recently
from
August 7, 2026 05:14
c01e6ae to
f7c76ef
Compare
Register uncaughtException and unhandledRejection handlers that write a best-effort crash report and exit non-zero, closing the gap between what the implementation notes described and what the code actually did. OpenTUI installs its own log-only handler for the same events, but Node calls every registered listener, so ours still runs and exits the process afterward. The crash directory is keyed the same way a session's own directory is, so a report lands next to that session's run state and transcript. That key resolution shells out to git with no timeout, so it is never done from the handler itself: the directory is resolved and cached once at startup, well before any crash, and the handler only ever reads the cached value with no further git calls.
TheGreatAxios
force-pushed
the
cl-5565-crash-handlers
branch
from
August 7, 2026 05:28
f7c76ef to
f19aa46
Compare
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
process.on("uncaughtException")andprocess.on("unhandledRejection")insrc/index.tsat startup~/.corbits/projects/<project-key>/errors/<timestamp>.txt, keyed the same wayprojectSessionsRootkeys a session's own directory, then callsprocess.exit(1)primeCrashReportingresolves and caches that directory once at startup, right after config load; the handler itself never callsprojectSessionsRoot(which shells out to git with no timeout), so a hung or corrupted git can never block the exit this change exists to forceVerification
bun run typecheck,bun run build, andbun testall pass, rebased ontoorigin/release/tui-bugfixes(4372 pass, 0 fail)src/crash/report.test.tscovers: report contents; the fail-open null-return path (a realmkdirfailure, not a mock); that the crash directory matchesprojectSessionsRootexactly; and the git-hang path specifically — a resolver that throws is called exactly once at priming time and never again fromcrashReportDir/writeCrashReport, proving the handler cannot re-trigger a hung git calluncaughtExceptionlistener (mirroring@opentui/core'sRenderer.handleError, confirmed innode_modules/.bun/@opentui+core*/.../chunk-node-0yw3x5m7.js) before and after our handler both terminate the process with exit code 1 in each ordering. No automated test exerciseshandleFatalor the registered handlers directly — the terminates-the-process property is verified only by that manual script, not bybun testrun.jsonun-finalized (status: "running", nofinishedAt), sincepersistRunSnapshotis a closure insiderunTUIcapturing local session state not reachable from the process-level handlerCloses CL-5565