Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): bound editor discovery during config loading #4291

Mergedmaria-rcksmerged 1 commit intomain fromrefs/pull/4291/headmerged by juliusmarminge View on GitHub

maria-rckscommented

What Changed

  • Bound optional editor discovery during server config loading to five seconds.
  • Return an empty availableEditors list when discovery times out.
  • Added regression coverage proving config loading completes and interrupts discovery when it never resolves.

Why

server.getConfig waits for optional editor discovery. On affected machines, discovery consumed almost the entire 15-second connection setup window, so the client timed out and entered a reconnect loop even though the server was running.

This keeps the fix at the config-loading seam and avoids the process-diagnostics and platform-specific changes proposed in #3911. Related symptom report: #3746.

Closes #3610

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Screenshots are not applicable; there are no UI changes
  • Video is not applicable; there are no animation or interaction changes

Note

Bound editor discovery in makeWsRpcLayer to a 5-second timeout

  • Introduces resolveAvailableEditorsForConfig in ws.ts, which wraps editor discovery with a 5-second timeout using Effect.timeoutOption.
  • The availableEditors field in the server config response now returns an empty array on timeout instead of blocking indefinitely.
  • Adds a test verifying that the discovery fiber is interrupted and an empty array is returned when discovery never resolves.
  • Behavioral Change: clients that previously waited for slow editor discovery will now receive an empty availableEditors list after 5 seconds.
Macroscope summarized 4bd5bcf.

Note

Low Risk Localized change to optional config metadata with graceful degradation; no auth or persistence impact.

Overview server.getConfig no longer waits indefinitely on optional editor discovery. Discovery is capped at 5 seconds via new resolveAvailableEditorsForConfig (Effect.timeoutOption); on timeout availableEditors is [] instead of holding the response.

This addresses clients timing out during connection setup when slow discovery consumed most of the setup window. A regression test asserts that after 5s the result is empty and the stuck discovery fiber is interrupted.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4bd5bcfa380941c5a7102b169e6195e744c97bb3. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
    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

      Run ID: 580c776a-bc14-419a-80fa-6be972e74a5e

      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
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      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. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4bd5bcfa380941c5a7102b169e6195e744c97bb3. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -3728,3 +3729,19 @@
      37283729 }).pipe(Effect.provide(NodeHttpServer.layerTest)),
      37293730 );
      37303731
      3732+ it.effect("does not block server config when editor discovery never resolves", () =>
      3733+ Effect.gen(function* () {
      3734+ const discoveryInterrupted = yield* Deferred.make<void>();
      3735+ const responseFiber = yield* resolveAvailableEditorsForConfig(
      3736+ Effect.never.pipe(
      3737+ Effect.onInterrupt(() => Deferred.succeed(discoveryInterrupted, undefined)),
      3738+ ),
      3739+ ).pipe(Effect.forkChild);
      3740+
      3741+ yield* TestClock.adjust(Duration.seconds(5));
      3742+
      3743+ const availableEditors = yield* Fiber.join(responseFiber);
      3744+ yield* Deferred.await(discoveryInterrupted);
      3745+ assert.deepEqual(availableEditors, []);
      3746+ }),
      3747+ );

      Timeout test missing yieldNow

      Medium Severity

      The new editor-discovery timeout test forks resolveAvailableEditorsForConfig over Effect.never, then calls TestClock.adjust without first yielding so the child fiber can register its timer. That diverges from the repo’s forkChild + TestClock.adjust pattern and can leave Fiber.join waiting forever, hanging CI.

      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4bd5bcfa380941c5a7102b169e6195e744c97bb3. Configure [here](https://www.cursor.com/dashboard/bugbot).
    4. Approvability

      Verdict: Needs human review

      The production code change is a low-risk defensive timeout addition. However, there's an unresolved comment about a potential test issue (missing yieldNow before TestClock.adjust) that could cause the test to hang, which warrants human attention.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. Windows cross-machine validation for 4bd5bcfa3 against merge-base 9a0a07167:

      Method

      • Applied the exact resolveAvailableEditorsForConfig boundary to the real Windows editor-discovery effect under a live Effect clock.
      • 5 serial measurements per revision, same warmed host/environment.
      • Windows build 26200.8875, AMD64, Windows PowerShell 5.1.26100.8875.
      • This isolates the editor-discovery portion of server.getConfig; it is not a complete Electron/renderer connection measurement.
      RevisionnminmedianmaxResult each run
      base 9a0a0716759,098.1 ms9,526.9 ms9,557.5 ms4 installed editors
      PR 4bd5bcfa355,000.1 ms5,000.4 ms5,009.1 ms[] after timeout

      That is a 47.5% median latency reduction and recovers about 4.5 seconds of the client's 15-second setup budget on this affected host.

      I also exercised a discovery effect that never resolves:

      • base/direct behavior was still pending when the 7,004 ms observation timeout fired;
      • PR behavior interrupted the discovery and returned [] in 5,008 ms.

      The PR's focused regression test passes locally: server.test.ts -t "does not block server config when editor discovery never resolves" — 1 passed, 112 skipped.

      The seam-level fix behaves as described. The observed tradeoff is also real: actual editor discovery takes about 9.5 seconds here, so every PR run used the timeout fallback and the initial config contained no installed editors. This looks useful as a connection-safety net; pairing it with faster/cached/background editor discovery would preserve the editor list without putting optional discovery back on the connection critical path.

    6. juliusmarminge merged this6e3b738

    7. juliusmarminge closed this

Sign in to join this conversation.