Repository navigation
fix(tui): surface worker defects instead of swallowing them - #532
Merged
Merged
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (3 files)
Previous Review Summaries (4 snapshots, latest commit 49cd9c9)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 49cd9c9)Status: No Issues Found | Recommendation: Merge Files Reviewed (1 file)
Previous review (commit d330354)Status: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Previous review (commit e8c880d)Status: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Previous review (commit 4096ec9)Status: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Reviewed by free · Input: 19.5K · Output: 967 · Cached: 107.3K |
Unhandled rejections and uncaught exceptions in the TUI worker were dropped by no-op handlers, so a defect in an RPC handler, bus listener or background job never logged, never settled the pending RPC and never engaged the subprocess crash-restart - the TUI footer just froze. - both defect classes are now logged and emitted to the main thread as a "worker.error" RPC event - the main thread translates that event into an error toast via the existing tui.toast.show event path - an uncaughtException in the subprocess exits 134 (the SIGABRT exit-code counterpart that isCrash classifies as a crash on every platform) so the crash-restart engages; a thread worker shares the UI process and only reports Fixes #396
agenteinstinct1-max
force-pushed
the
fix/396-worker-defects
branch
from
October 22, 2026 19:04
4096ec9 to
e8c880d
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.
Issue for this PR
Closes #396
Type of change
What does this PR do?
packages/opencode/src/cli/tui/worker.tsregistered no-op handlers forunhandledRejectionanduncaughtException, so any defect in an RPC handler, a GlobalBus projection or a background job never reached logging, never settled the pending RPC call, and never engaged the worker-process crash-restart (isCrashonly sees signal/exit code, and a swallowed defect produces neither). The main thread saw an RPC hang and the TUI footer froze with no toast.Changes:
worker.errorRPC event carrying message, stack and a fatal flag. The handler construction is a pure exported factory (createDefectHandlers) so the contract is unit-testable, matching theresolveIsTuiWorkerprecedent.createEventSourceinpackages/opencode/src/cli/cmd/tui.ts) subscribes toworker.errorand translates it into the existingtui.toast.showevent, so the defect appears as an error toast ("Backend worker error" / "Backend worker crashed") instead of a silent freeze.uncaughtExceptionin the subprocess additionally exits with code 134 after a short flush delay. 134 is the exit-code counterpart of SIGABRT andisCrashclassifies it as a crash on every platform, so the existing crash-restart engages. A thread worker shares the UI process and only reports; it must not exit.unhandledRejectionreports but keeps the worker alive: rejections from fire-and-forget listeners are frequently recoverable and killing the backend for one would be worse than the toast.How did you verify your code works?
New suite
packages/opencode/test/cli/tui-worker-defects.test.ts(4/4 pass): rejection reported non-fatal with no exit; non-Error rejection stringified; subprocess uncaughtException reported fatal and exits 134; thread worker reports fatal but never exits the shared process. Existingtui-bootstrapandworker-processsuites still pass (15/15). Repo-wide typecheck is left to CI (the sandbox cannot hold it in memory).Screenshots / recordings
No visual change: the toast uses the existing tui.toast.show path.
Checklist