Repository navigation
fix(link): proxy_no_first_frame resilience — per-slot backoff + request-leg republish - #3704
Merged
Merged
Conversation
Contributor
🧪 BenchmarkShould we run the Virtual MCP strategy benchmark for this PR? React with 👍 to run the benchmark.
Benchmark will run on the next push after you react. |
…st-leg republish (TDD, all gates green) Fixes #3698-follow: cluster-daemon proxy channel now tolerant of transient subscriber gaps. PART #1 — Per-slot backoff (proxy-poller.ts) - Root cause: shared errorStreak across proxy concurrency slots. One systemic error (e.g. Cloudflare 520 on the 28s long-poll) backed off BOTH slots → 1–30s zero-subscriber gap → dispatch publish to links.proxy.req.<userSub> dropped → proxy_no_first_frame 15s later. - Fix: move errorStreak into each slot(). Each slot backs off only its own failures; one recovering slot re-polls immediately while another retries, keeping ≥1 live subscriber through intermittent errors. - Test: new "per-slot backoff" test with concurrency:2 asserts seenStreaks=[0,0] not [0,1]. PART #2 — Request-leg tolerance (link-proxy-routes.ts, proxy-poller.ts) - Root cause: fire-and-forget core-NATS publish with no buffer. A single blind publish is lost if it lands in a daemon poll/backoff gap; no retry, no durability. - Fix: cluster-side bounded republish + daemon reqId dedup. (A) proxy-abort-registry.register() now returns AbortController|null; null if reqId already in-flight (duplicate delivery dedup). handleProxyRequest bails on null before try/finally, so duplicate copy doesn't unregister the original. (B) createProxyDispatch republishes RequestFrame every 1s (injectable republishIntervalMs, 0=off) until first reply frame. Stopped by markFirstFrame/cleanup/first-frame-timeout (never outlives dispatch, bounded by 15s window). Daemon dedup makes double-execution impossible (emits first frame only after upstream responds). - Tests: registry dedup test + "re-publishes...then stops" cluster test. Verification: 36 affected-test pass, 110 link tests pass, fmt/lint/typecheck clean.⚠️ Daemon caveat: proxy-abort-registry.ts marked "SHIPPED DAEMON — needs human review before merge." Small change, well-tested, but shipped in `decocms` CLI. Remaining: #3 tie proxy-readiness to claim (doc-vs-code defect), infra fix for CF 520, plus this dedup safety pattern may apply elsewhere (runAbortRegistry in thread-gate-workflow). Co-Authored-By: Claude Haiku 4.5 <[email protected]>
tlgimenes
force-pushed
the
tlgimenes/proxy-no-first-frame-debug
branch
from
June 8, 2026 13:58
a4bac51 to
e49aa9e
Compare
decocms Bot
pushed a commit
that referenced
this pull request
Jun 8, 2026
PR: #3704 fix(link): proxy_no_first_frame resilience — per-slot backoff + request-leg republish Bump type: patch - decocms (apps/mesh/package.json): 2.398.1 -> 2.398.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes dropped dispatches on the pull proxy channel when the daemon has transient subscriber gaps.
Root cause:
errorStreakacross proxy-poller concurrency slots: one systemic error (Cloudflare 520 on the 28s long-poll) backs off BOTH slots → 1–30s zero-subscriber window./work(not/proxy), so presence-loss fail-fast can't catch a dead proxy-poll while the link looks "connected."Result: chat messages fail with
[remoteDispatch] proxy_no_first_frame: no reply frame within first-frame timeoutbecause the cluster's RequestFrame publish lands in a gap and is dropped. Cluster waits 15s with no reply, fails fast instead of hanging.Changes
PART #1 — Per-slot backoff
apps/mesh/src/link-daemon/proxy-poller.tserrorStreakfrom shared scheduler scope into eachslot()closure.PART #2 — Request-leg tolerance
apps/mesh/src/api/routes/decopilot/link-proxy-routes.tsrepublishIntervalMs, default=1000, 0=off) until first reply frame arrives.apps/mesh/src/link-daemon/proxy-abort-registry.ts+apps/mesh/src/link-daemon/proxy-poller.tsregister(reqId)now returnsAbortController | null— null if reqId already in-flight (dedup for republish duplicates).handleProxyRequestbails on null before try/finally, so duplicate copy is skipped without unregistering the original's controller.Test Plan
bun test apps/mesh/src/link-daemon/proxy-abort-registry.test.ts— 7 pass (including new dedup test)bun test apps/mesh/src/link-daemon/proxy-poller.test.ts— 14 pass (including new per-slot test)bun test apps/mesh/src/api/routes/decopilot/link-proxy-routes.test.ts— 16 pass (including new republish test)bun run fmt— clean (no fixes)bun run check— all workspaces exit 0bun run lint— 0 warnings / 0 errorsNotes
proxy-abort-registry.tsmarked "SHIPPED DAEMON — needs human review before merge." The change is small and well-tested (7 existing + 1 new test), but shipped in thedecocmsCLI binary, so users must update theirdeco linkfor Part A's dedup to take effect. This is safe (the change is purely defensive — returns null instead of a controller) but worth careful review.Remaining work:
link-proxy-routes.ts:407claims work/control/proxy all re-arm the 60s claim TTL, but only/workdoes — a real doc-vs-code defect. Once Chore: migrate chat and agent-settings #3 is done, a dead proxy-poll surfaces a cleanlink_unavailableinstead of a 15s hang.reqIddedup pattern in this PR may apply torun-abort-registryinthread-gate-workflow.tsif similar republish lands there.🤖 Generated with Claude Code
Summary by cubic
Makes the link proxy resilient to transient subscriber gaps by adding per-slot backoff in the daemon and bounded request-leg republishing with reqId dedup. Prevents dropped request publishes that triggered proxy_no_first_frame timeouts.
Bug Fixes
republishIntervalMs(0 disables).register(reqId)returnsAbortController | null; duplicates are skipped to avoid double execution.Migration
decocmsCLI (updatedeco link) so the dedup change takes effect.Written for commit a4bac51. Summary will update on new commits.