Skip to content

perf(desktop): a starting local backend no longer delays connecting to the primary by 10 s - #237

Merged
tusharbhardwaj-bk merged 1 commit into
expbkmainfrom
t3code/desktop-local-discovery-timeout
Sep 27, 2026
Merged

tusharbhardwaj-bk merged 1 commit into
expbkmainfrom
t3code/desktop-local-discovery-timeout

Conversation

@tusharbhardwaj-bk

Copy link
Copy Markdown
Collaborator

Problem. Reopening the managed desktop app ("StageBKT3Code") sometimes took about 10 s before any message synced. The expbkt3 traces for this app show the same gap on 2 of 3 window opens (08:34:51 → 08:35:02 and 14:13:53 → 14:14:03 on 2026-09-27): the renderer fetched /api/auth/session, /api/orchestration/users and /.well-known/t3/environment straight away, then waited ~10.5 s before it requested a WebSocket ticket.

Cause. buildPlatformRegistrations builds every registration before returning any. After the primary it walks the desktop-local backends one by one. A managed build registers its bundled backend and starts it after the window opens. While that backend is starting, its readiness middleware holds every request, so the descriptor fetch waited out its default 10 s timeout. The primary was installed, and the supervisor allowed to connect, only after that. The loopback requests never reach the remote server, which is why its traces show an empty gap.

Fix. Pass a 1.5 s timeoutMs to the desktop-local descriptor fetch (desktopLocalDiscovery.expbkt3.ts, one marked seam in platform.ts). A ready loopback backend answers in milliseconds. One still starting is skipped for this poll and retried on the next, 3 s later. The bearer bootstrap is untouched: it runs only once the descriptor has answered, and by then the backend is ready.

Verification.

  • Web typecheck and lint are clean.
  • No unit test: the change is a timeout value, and the platform source has no test harness.
  • The proof is the next window open on a staging desktop build: the gap between /.well-known/t3/environment and /api/auth/websocket-ticket in the expbkt3 traces should be under 2 s.

🤖 Generated with Claude Code

…o the primary by 10 s

The platform source builds every registration before handing any to the
registry, so the remote primary only connects once each desktop-local backend
has described itself. A managed build starts its bundled backend after the
window opens, and a backend still starting holds requests until it is ready,
so the descriptor fetch waited out its 10 s timeout. Cap it at 1.5 s; a ready
loopback backend answers in milliseconds and a slow one is retried on the
next 3 s poll.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S labels Sep 27, 2026
@github-actions

Copy link
Copy Markdown

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire — 13.8 KiB — 15.1 KiB ✅
Codex Thread snapshot wire — 7.3 KiB — 7.8 KiB ✅
Codex Live turn WebSocket wire — 6.5 KiB — 7.8 KiB ✅
Codex Live turn WebSocket decoded — 57.1 KiB — 66.4 KiB ✅
Codex Live turn messages — 9 — 21 ✅
Claude Total thread wire — 13.8 KiB — 15.1 KiB ✅
Claude Thread snapshot wire — 7.3 KiB — 7.8 KiB ✅
Claude Live turn WebSocket wire — 6.5 KiB — 7.8 KiB ✅
Claude Live turn WebSocket decoded — 57.9 KiB — 66.4 KiB ✅
Claude Live turn messages — 9 — 21 ✅

Baseline: unavailable · PR result: a722a0e · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 114.9 KiB
  • Claude decoded thread snapshot: 115.6 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@tusharbhardwaj-bk
tusharbhardwaj-bk merged commit 6ffea6a into expbkmain Sep 27, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants