Skip to content

perf(sync): carry every sync source over one socket - #358

Merged
Makisuo merged 2 commits into
mainfrom
perf/sync-mux
Oct 31, 2026
Merged

Makisuo merged 2 commits into
mainfrom
perf/sync-mux

fix(sync): close a stream's object socket when the stream closes mid-…

920af6f
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review succeeded Oct 31, 2026 in 22s

Confidence 8/10 · No issues found

🟢 Confidence 8/10 · likely safe to merge. Held at 8 because earlier reviews of this pull request found 1 defect.
no findings · tests covered · risk high −1 · 1 defect fixed in earlier rounds

Follow-up to the sync mux: open is now the acquire of an acquireRelease, so a stream closed while its object socket is still being opened closes that socket instead of leaking it. Safe to merge.

  • relay opens the object socket as an acquireRelease acquire, closing it in the release
  • New test covers a Close arriving while the object is still answering

Fixed since the last review

  • ✅ F1 · A stream closed while it is still opening leaks its object socket

Production impact

Production traffic of the changed files (last 7 days)
File Calls/day Busiest operations
apps/backend/src/worker/sync-route.ts 1.7k GET 964/day, 1.4% err
GET 704/day, 11.1% err
Telemetry this change adds and removes (3)
  • ➕ span name SyncMux.open · apps/backend/src/worker/sync-route.ts:290
  • ➕ attribute sync.source · apps/backend/src/worker/sync-route.ts:291
  • ➕ span name SyncRoute.muxUpgrade · apps/backend/src/worker/sync-route.ts:329
What was checked
  • acquireRelease masks the acquire uninterruptibly and registers the release as a finalizer (internal/effect.ts:3800)
  • FiberMap.remove awaits the interrupt (FiberMap.ts:573), so the release runs before the Close frame is done
  • The regression test pins the mid-open Close: before the fix the answer arrives with nothing to close it

920af6f · Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.