Skip to content

fix(client-runtime): capture ping timeout and close codes on disconnect - #168

Merged
patroza merged 1 commit into
fork/changesfrom
t3code/fix-disconnect-detail-capture
Jul 29, 2026
Merged

fix(client-runtime): capture ping timeout and close codes on disconnect#168
patroza merged 1 commit into
fork/changesfrom
t3code/fix-disconnect-detail-capture

Conversation

@patroza

@patroza patroza commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #163. Diagnostics still reported bare t3vm disconnected. because:

  1. onDisconnect races the browser close event — Effect fails the protocol (and runs the hook) before the async close event populates our capture, and for ping timeout the socket is still open (cleanup closes with 1000 later).
  2. We never used the forked Effect onPingTimeout hook (already in patches/effect@4.0.0-beta.102).

Fix

  • Record causes in a sink via onPingTimeout + wrapping Socket.runRaw (SocketCloseError codes / open errors) before formatting.
  • Format detail with causeMessage → e.g. t3vm ping timeout. / t3vm closed (1006 abnormal).
  • Map open/ping failures to reason: "timeout" when appropriate.
  • Tests for ping timeout (TestClock 10s) and 1006 close.

Root cause of the reconnect storms (Jaeger, not fixed here)

Guest t3-server-vm sessions thrash on VCS status (runGitCommand × hundreds, multi-minute subscribeVcsStatus). Host under memory pressure (swap full) + 5s Effect RPC ping → late pongs → disconnect → reconnect. This PR makes that visible; ops/VCS load is separate.

Test plan

  • session.test.ts ping timeout + 1006 + open timeout paths
  • vp check
  • Full monorepo typecheck
  • After deploy: disconnect log shows ping timeout / close code, not bare disconnected.

onDisconnect ran before browser close events and ignored the patched
onPingTimeout hook, so diagnostics collapsed to a bare "disconnected."
Record SocketError causes and ping timeouts before formatting detail.
@patroza
patroza merged commit b296887 into fork/changes Jul 29, 2026
12 checks passed
patroza added a commit that referenced this pull request Jul 29, 2026
…ct (#168)

onDisconnect ran before browser close events and ignored the patched
onPingTimeout hook, so diagnostics collapsed to a bare "disconnected."
Record SocketError causes and ping timeouts before formatting detail.

Co-authored-by: T3 Code PR Stack <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant