Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): bound relay environment unlink with a 5s timeout #14132

Closedkvnloo(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/14132/headopened View on GitHub

What Changed

unlinkRelayEnvironment (the relay half of t3 connect disconnect) now has a 5s deadline (CLOUD_CLI_LIVE_SERVER_TIMEOUT), applied right after httpClient.execute in apps/server/src/cli/connect.ts.

Why

The relay DELETE ran with no deadline, while the sibling live-server unlink step was already bounded by the same 5s timeout. A wedged relay hung the entire t3 connect disconnect command forever -- and the local cleanup (clearPersistedCloudLink, credential clear) sits after the unbounded Effect.exit(unlinkRelayEnvironment()), so it never ran either. The caller already absorbs failure through reportCloudDisconnectResults, which logs the cause and tells the user to retry.

Validation

  • New test in connect.test.ts stalls the HttpClient under TestClock: the stalled unlink now fails with TimeoutError after 5s. 8/8 tests green.
  • Red on base: without the timeout the new test hangs until the 20s test timeout and fails -- the defect is literally a hang.
  • vp fmt --check clean; tsc --noEmit reports no errors in the touched files.

Checklist

  • This PR is small and focused
  • I have tested the change

AI-assisted: authored with AI assistance (Muse, Meta's Muse Spark) under the contributor's direction.

Summary by CodeRabbit

  • Bug Fixes
    • Relay environment unlink requests now time out after five seconds instead of waiting indefinitely. A timeout is reported as a failure.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

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

      🟠 High cli/connect.ts:347

      A relay that sends response headers and then stalls its JSON body makes unlinkRelayEnvironment hang indefinitely, so disconnectCloud never reaches local cleanup. Effect.timeout currently wraps only httpClient.execute, leaving filterRelayResponse and schemaBodyJson outside the deadline; move the timeout after the full execute/filter/decode pipeline.

           httpClient.execute,
      -    // Mirror runLiveCloudUnlink: a wedged relay must not hang `t3 connect
      -    // disconnect` (and its local cleanup) forever. The caller already absorbs
      -    // failure via Effect.exit.
      -    Effect.timeout(CLOUD_CLI_LIVE_SERVER_TIMEOUT),
           Effect.flatMap(filterRelayResponse),
           Effect.flatMap(HttpClientResponse.schemaBodyJson(RelayOkResponse)),
      +    // Mirror runLiveCloudUnlink: a wedged relay must not hang `t3 connect
      +    // disconnect` (and its local cleanup) forever. The caller already absorbs
      +    // failure via Effect.exit.
      +    Effect.timeout(CLOUD_CLI_LIVE_SERVER_TIMEOUT),
           withRelayClientTracing,
      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/cli/connect.ts around lines 347-355:
      
      A relay that sends response headers and then stalls its JSON body makes `unlinkRelayEnvironment` hang indefinitely, so `disconnectCloud` never reaches local cleanup. `Effect.timeout` currently wraps only `httpClient.execute`, leaving `filterRelayResponse` and `schemaBodyJson` outside the deadline; move the timeout after the full execute/filter/decode pipeline.
    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Would Approve

      Macroscope's review found this PR approvable — This is a narrowly scoped timeout bug fix with a targeted regression test and no schema, deployment, security, billing, or static-analysis changes. An unresolved High-severity finding indicates that stalled response-body decoding can still bypass the deadline, so the implementation’s hang prevention is incomplete.

      Not approved because:

      • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Review in Change Stack →

      Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

      Review profile: CHILL

      Plan: Advanced

      Run ID: ac7e34f0-89f2-40af-9821-26c0d1dbfb3a

      📥 Commits

      Reviewing files that changed from the base of the PR and between ed57bed8e71b2e89a9350c94bda0dacc71cd4817 and abaab3f0acd7436a87d02938b7b7e113990e2f47.

      📒 Files selected for processing (2)
      • apps/server/src/cli/connect.test.ts
      • apps/server/src/cli/connect.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.


      📝 Walkthrough

      Walkthrough

      The relay unlink function is now exported and applies a five-second timeout to its HTTP request. A test verifies that a request that never completes fails with TimeoutError.

      Changes

      Relay unlink timeout

      Layer / File(s)Summary
      Apply and verify relay unlink timeout
      apps/server/src/cli/connect.ts, apps/server/src/cli/connect.test.ts
      The relay unlink request now uses a five-second timeout. The test advances the clock by five seconds and checks for TimeoutError when the HTTP request does not complete.

      Priority: ➖ Normal

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to abaab

      No actionable merge-blocking risk is established for the relay unlink timeout; merge after normal checks.

      Security Architecture Review

      Security architecture risk: 🔵 Low · up to abaab

      A stalled relay no longer blocks local cleanup. Sign-out can now finish while relay revocation is unconfirmed, although the command warns about that outcome. No new external entrypoint or change in request authorization was found.

      Retained concerns

      • Low · security · inferred: On timeout, logout can clear local link state and CLI credentials without confirmation that the relay-side environment record was revoked. The command warns the user, but remote completion after timeout is unknown.
      Security review details

      Security Blast Radius

      • inferred — The directly evidenced divergence is between local cleanup and revocation of the addressed relay environment link. Evidence does not establish broader tenant reach or continued access through an unrevoked record.

      Security Findings and Attack Paths

      • inferred — A relay request that exceeds the deadline can leave remote revocation unconfirmed when local sign-out completes. No new attacker-controlled production entrypoint or verified exploit path was identified.

      Trust Boundaries and Controls

      • observed — The existing bearer-token check precedes the relay request. Failure is captured and reported, with different recovery guidance depending on whether local authorization was retained.

      Resilience and Maintainability Implications

      • inferred — Retaining credentials on unlink supports a retry after timeout. Logout deliberately removes them, so recovery from an unconfirmed relay revocation may require renewed authorization; remote completion and retry behavior remain unverified.
      🚥 Pre-merge checks | ✅ 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly and concisely describes the main change: adding a five-second timeout to relay environment unlinking.
      Description check✅ PassedThe description explains what changed, why the timeout is needed, and how the change was validated. It includes the required checklist and correctly omits the non-applicable UI section.
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR

      Comment `@coderabbitai help` to get the list of available commands.
    5. juliusmarminge added labelsmacroscope-review

    6. Note

      Written by claude-opus-5-5 on behalf of Maria

      Hi! We are cleaning up open PRs, and this one does not say which model or harness was used to create it. If this change is really important, we recommend rebuilding the PR with a newer model and noting the model and harness in the PR description.

    7. maria-rcks closed this

Sign in to join this conversation.