fix(desktop): classify quit-time terminal-host disposal as typed non-500
Merged
SA
3mo ago+63+63+01234567890123456789-20-20-01234567890123456789
Summary
Refs DESKTOP-HD: a normal app quit racing an in-flight terminal request was being reported as a 500.
During quit, runQuitCleanup → disposeTerminalHostClient → dispose → disconnect → resetConnectionState rejected every pending terminal-host request with a generic Error("Connection lost"). An in-flight terminal.createOrAttach mutation then surfaced that as INTERNAL_SERVER_ERROR, which the Sentry tRPC middleware captures.
Changes
Per the error-handling contract (#6164 — typed causes at throw sites, never a Sentry filter):
TerminalHostClient.disconnect()(the intentional teardown path:dispose/shutdown) now rejects pending requests with a typedTerminalHostClientDisposedErrorinstead of the generic error.- The
terminal.createOrAttachcatch translates that error toPRECONDITION_FAILEDwithcause: { kind: "TERMINAL_HOST_CLIENT_DISPOSED" }, so it never reaches the Sentry middleware as a 500. - Genuine unexpected connection loss (
handleDisconnecton socket drop, connect-failure resets) keeps the genericError("Connection lost")rejection and still reports.
Verification
bunx biome checkclean on both changed filescd apps/desktop && bun run typecheckpasses
https://claude.ai/code/session_017sk3KSZ5NLrpTedKWRX2k8
Summary by cubic
Prevent normal app quit from being reported as a 500 when a terminal request is in flight. Quit-time terminal-host teardown now uses a typed error and maps to a non-500 tRPC code.
- Bug Fixes
- Added
TerminalHostClientDisposedError; used on explicitdisconnect/disposeto reject pending requests. - In
terminal.createOrAttach, translate this toPRECONDITION_FAILEDwithcause: { kind: "TERMINAL_HOST_CLIENT_DISPOSED" }; unexpected socket drops keep the generic "Connection lost" and still report.
- Added
Summary by CodeRabbit
- Bug Fixes
- Improved terminal connection error handling during intentional shutdowns.
- Standardized error responses when terminal sessions are disposed.
- Preserved clear “connection lost” messaging for unexpected disconnects.
- Improved handling of pending terminal requests during connection resets.