Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): one disconnecting client no longer blocks every reconnect #5572

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/5572/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

My machine stopped accepting connections and stayed broken. Reloading did nothing. The server was healthy and the relay was fine: the WebSocket authenticated, then the very first RPC died and the socket closed ~100ms later, on every attempt.

Editor discovery is memoized with Effect.cachedWithTTL, which stores whatever Exit the first caller produces — including an interrupt. Callers run it on the connection fiber under a timeout, so a client that disconnects mid-scan caches the interrupt. Every later connect then replays it, server.getConfig fails, and nothing can reconnect. Worse, each failed connect re-runs discovery and re-poisons the cache, so the 60s TTL keeps refreshing and it never self-heals. Only a restart clears it.

Cache the discovered set only on success. An interrupted scan now leaves the cache untouched and the next connect simply rescans. The memoization that #5561 added is preserved.

Trace from the stuck server, showing where the connection died:

EnvironmentAuth.authenticateWebSocketUpgrade  Success
SessionStore.markConnected                    Success
ws.rpc.server.getConfig                       Interrupted
SessionStore.markDisconnected                 Success

The regression test reproduces this: it fails on the current code with the same interrupt through the same isExecutableFile → resolveAvailableCommand stack, and passes with the fix. Verified by reverting the source and re-running. Full server suite: 1,901 passing, typecheck clean.

Introduced by #5561, which is in nightly .1021.

Made by Claude Opus 5 in Claude Code.


Note

Medium Risk Touches connection-time config path (getConfig / editor discovery) with custom caching semantics; scope is narrow and covered by a targeted regression test.

Overview Editor discovery memoization no longer caches interrupts, fixing reconnects that failed on every server.getConfig until restart.

ExternalLauncher.resolveAvailableEditors drops Effect.cachedWithTTL for a Ref-backed cache that writes only after a successful PATH scan. If discovery is interrupted (e.g. client disconnect mid-connect on the connection fiber), the cache stays empty and the next connect rescans instead of replaying the interrupt for the full 60s TTL. TTL expiry uses Clock.currentTimeNanos (monotonic), aligned with shell command-resolution caching.

A regression test interrupts discovery mid-scan and asserts a later call still returns editors.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 76d0847b01ac5dfdb98e91dfbd54f7563121625c. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Fix resolveAvailableEditors to skip caching interrupted or failed discoveries

  • Effect.cachedWithTTL was replaying cached interrupts, blocking reconnects when a client disconnected mid-discovery. Replaced with a manual Ref-backed cache in externalLauncher.ts.
  • The new cache only stores successful results and uses a monotonic nanosecond TTL (60_000_000_000n) via Clock.currentTimeNanos to avoid system clock skew issues.
  • A regression test in externalLauncher.test.ts verifies that an interrupted discovery is not cached and a subsequent call rescans correctly.
Macroscope summarized 76d0847.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: f77e6b4c-a163-490e-a9d4-04a83305a282

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved 76d0847

      Straightforward bug fix replacing Effect.cachedWithTTL with a custom success-only cache to prevent client disconnection interrupts from being cached and replayed. Well-documented with clear intent, limited scope, and includes a regression test.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).

Sign in to join this conversation.