Repository navigation
fix(e2ee): stop dropping terminal output on a backed-up legacy connection - #26528
Conversation
An idle page sends no next frame, so a refused last frame left the viewer on a stale picture. The desktop's relay leg to a server uses legacy E2EE, which drops on a full socket where a direct v2 phone queues; retrying the newest pending frame restores parity. Retries never count toward ghost eviction. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…them Legacy E2EE (every direct phone, the desktop's server link) sent binary straight to the socket and silently dropped it once the outbound budget was full, so terminals lost output and binary could overtake queued text. Binary now shares the ordered text queue and closes on overflow like v2; the lossy screencast opts into dropWhenBacklogged and its retry delivers the newest frame after a drain. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… as a ghost A lossy frame skipped on a busy socket returned false like a dead socket, so a long backlog evicted a live viewer. Skips now return 'backlogged', which retries without counting toward eviction; legacy judges idleness on the sealed size before encrypting, so skipped frames cost no encryption. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to If screencast startup fails after a frame was already refused, a retry timer can keep running against the failed subscriber. This is a narrow edge case with a small fix, so it can be addressed as a follow-up. Pre-merge checks |
|
…y-queue # Conflicts: # src/main/runtime/rpc/core.ts # src/main/runtime/rpc/dispatcher-stream-options.ts # src/main/runtime/runtime-rpc/runtime-rpc-websocket-dispatch.ts
The pre-ready gate now passes the per-frame send options through to the socket sender, so the replayed startup frame arrives with an options slot. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Main's renderer throttle lease now calls setBackgroundThrottling on the guest,
so the bare { isDestroyed } guest in two branch tests threw. One shared double
keeps all three screencast suites on the shape the lease needs.
Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
656e5c00-400d-4603-99ee-3f18e8b740c6
📒 Files selected for processing (10)
src/main/runtime/orca-runtime-browser-screencast-e2ee-backlog.test.tssrc/main/runtime/orca-runtime-browser-screencast-fanout.test.tssrc/main/runtime/orca-runtime-browser-screencast-pending-frame-retry.test.tssrc/main/runtime/orca-runtime-browser.test.tssrc/main/runtime/orca-runtime-tests/mobile-creation-and-orchestration.spec.tssrc/main/runtime/rpc/core.tssrc/main/runtime/rpc/methods/terminal/terminal-multiplex-frame-delivery.tssrc/main/runtime/runtime-browser-commands-browser-screencast.tssrc/main/runtime/runtime-rpc/runtime-rpc-websocket-dispatch.tssrc/main/runtime/single-page-browser-commands-host-test-double.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| subscriber.pendingFrame = delivered ? null : bytes | ||
| subscriber.delivery = recordScreencastSubscriberSend(subscriber.delivery, delivered) | ||
| // A slow viewer drops this frame without stalling every other viewer. | ||
| deliverScreencastSubscriberFrame(subscriber, bytes) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
set -eu
printf '%s\n' '--- diff summary ---'
git diff --stat 4c4f1ee18c8948cce8cab26d6f9ca29c3b2395a5 90ce943a6e7800a9f652d540d828a4d9e0ba703e -- src/main/runtime/runtime-browser-commands-browser-screencast.ts src/main/runtime/browser-screencast-subscriber-frame-delivery.ts
printf '%s\n' '--- screencast file ---'
nl -ba src/main/runtime/runtime-browser-commands-browser-screencast.ts | sed -n '1,230p'
printf '%s\n' '--- delivery helper ---'
nl -ba src/main/runtime/browser-screencast-subscriber-frame-delivery.ts | sed -n '1,260p'
printf '%s\n' '--- startBrowserScreencast references ---'
rg -n -F --glob '*.ts' -- 'startBrowserScreencast' src tests || true
printf '%s\n' '--- browser screencast tests/references ---'
rg -n -F --glob '*.{ts,tsx}' -- 'browserScreencast' src tests || trueRepository: stablyai/orca
Length of output: 36555
🏁 Script executed:
set +e
printf '%s\n' '--- changed-file diff ---'
git diff --unified=80 4c4f1ee18c8948cce8cab26d6f9ca29c3b2395a5 90ce943a6e7800a9f652d540d828a4d9e0ba703e -- src/main/runtime/runtime-browser-commands-browser-screencast.ts src/main/runtime/browser-screencast-subscriber-frame-delivery.ts
printf '%s\n' '--- screencast file ---'
nl -ba src/main/runtime/runtime-browser-commands-browser-screencast.ts | sed -n '1,230p'
printf '%s\n' '--- delivery helper candidates ---'
find src -type f -iname '*screencast*' -print
printf '%s\n' '--- startBrowserScreencast references ---'
rg -n -F --glob '*.ts' -- 'startBrowserScreencast' src tests 2>/dev/null || true
printf '%s\n' '--- browser screencast references ---'
rg -n -F --glob '*.ts' -- 'browserScreencast' src tests 2>/dev/null || trueRepository: stablyai/orca
Length of output: 41800
🏁 Script executed:
printf '%s\n' '--- source files ---'
nl -ba src/main/runtime/runtime-browser-commands-browser-screencast.ts | sed -n '1,230p'
find src -type f -iname '*screencast*' -print
printf '%s\n' '--- delivery helper ---'
for f in $(find src -type f -iname '*screencast*' -print); do
case "$f" in
*subscriber*delivery*) nl -ba "$f" | sed -n '1,280p';;
esac
done
printf '%s\n' '--- startBrowserScreencast references ---'
rg -n -F --glob '*.ts' -- 'startBrowserScreencast' src tests 2>/dev/null || true
printf '%s\n' '--- browserScreencast references ---'
rg -n -F --glob '*.ts' -- 'browserScreencast' src tests 2>/dev/null || trueRepository: stablyai/orca
Length of output: 38718
🏁 Script executed:
pwd
git status --short
nl -ba src/main/runtime/runtime-browser-commands-browser-screencast.ts | sed -n '1,210p'
printf '%s\n' '--- files ---'
find src -type f -iname '*screencast*' -printRepository: stablyai/orca
Length of output: 12602
🏁 Script executed:
printf '%s\n' '--- startBrowserScreencast implementation ---'
nl -ba src/main/browser/browser-screencast-stream.ts | sed -n '1,280p'
printf '%s\n' '--- startup failure and first-frame tests ---'
nl -ba src/main/browser/browser-screencast-first-frame-timeout.test.ts | sed -n '1,180p'
nl -ba src/main/browser/browser-screencast-lifecycle.test.ts | sed -n '1,150p'
printf '%s\n' '--- runtime startup-failure tests ---'
nl -ba src/main/runtime/browser-screencast-renderer-throttle-lease.test.ts | sed -n '90,230p'
nl -ba src/main/runtime/orca-runtime-browser-screencast-fanout.test.ts | sed -n '115,180p'Repository: stablyai/orca
Length of output: 30636
🏁 Script executed:
nl -ba src/main/browser/browser-screencast-stream.ts | sed -n '1,320p'
printf '%s\n' '--- first-frame timeout ---'
nl -ba src/main/browser/browser-screencast-first-frame-timeout.test.ts | sed -n '1,180p'
printf '%s\n' '--- runtime startup failure ---'
nl -ba src/main/runtime/browser-screencast-renderer-throttle-lease.test.ts | sed -n '90,230p'Repository: stablyai/orca
Length of output: 21912
🏁 Script executed:
printf '%s\n' '--- CDP message handler ---'
nl -ba src/main/browser/browser-screencast-cdp-events.ts | sed -n '1,280p'
printf '%s\n' '--- frame pacer ---'
nl -ba src/main/browser/browser-screencast-frame-pacer.ts | sed -n '1,300p'
printf '%s\n' '--- admission contract ---'
nl -ba src/main/runtime/remote-browser-screencast-frame-admission.ts | sed -n '1,180p'Repository: stablyai/orca
Length of output: 12031
🏁 Script executed:
nl -ba src/main/browser/browser-screencast-cdp-events.ts | sed -n '1,280p'
nl -ba src/main/browser/browser-screencast-frame-pacer.ts | sed -n '1,300p'
nl -ba src/main/runtime/remote-browser-screencast-frame-admission.ts | sed -n '1,180p'Repository: stablyai/orca
Length of output: 11956
Cancel the retry before deleting a failed subscriber.
startBrowserScreencast accepts frame events while startup is pending. If a subscriber refuses such a frame and startup then fails, the catch deletes the subscriber before the chained stream finalizer cancels its retry. The retry can continue against the failed subscriber.
🐛 Suggested fix
} catch (error) {
+ const subscriber = active.subscribers.get(subscriptionId)
+ if (subscriber) {
+ cancelScreencastSubscriberFrameRetry(subscriber)
+ }
active.subscribers.delete(subscriptionId)
resolveSubscriberDone()
throw error
ELI5
When a phone's connection to Orca was backed up, terminal output could be silently thrown away, so text
went missing from the phone's terminal. Output could also arrive out of order. Terminal output now waits in
line like everything else. Browser pictures are the one stream allowed to skip frames, and the newest
picture still arrives once the connection catches up.
What Changed
Before:
channel. On that channel, a binary reply (terminal output, browser pictures) was dropped once the server
had 32 MiB of unsent data across its sockets.
terminal.subscribeignored the failure, and the phone hasno gap check, so output went missing silently.
page could stay stuck on an old picture.
After:
before queueing (legacy uses a random nonce per message, so there is no counter hazard). If the queue
overflows, the socket closes (1013), as text already did and v2 already does. Clients then reconnect
and reload.
{dropWhenBacklogged}on the binary sender (new shared typeRpcBinarySender) skips the frame without queueing while the socket is busy, and returns'backlogged'. Only the browser screencast passes it, on both the legacy channel and v2. On legacy,idleness is checked before encrypting, so skipped frames cost nothing.
frame and is retried every 50 ms until it's delivered, replaced by a newer frame, or the viewer leaves.
false) counts toward evicting a ghost viewer. A merelybacklogged one doesn't, so a terminal burst can't get a phone dropped from a browser page.
Why
Terminal output must never be lost, and browser pictures are only useful if they're current. One rule
covers both: lossless streams queue, and the single lossy stream skips frames but always ends on the
newest. Upgrading those connections to v2 was considered, but it's a 300–500 line handshake change, and
it would still leave legacy clients broken.
Linked Issue
N/A (maintainer)
Visual Proof
N/A. Delivery behaviour under backpressure; no UI change.
Testing
Automated tests added/updated, or explained why not below
Legacy channel: with a tiny budget, text, binary, text, binary all arrive in order. A full queue
closes the socket. A lossy frame is skipped, not queued. Each of these failed on the old code.
v2: a lossy frame is skipped without spending a message counter.
Real legacy
E2EEChannelplus real screencast fan-out: the socket is held busy while 100 frames areproduced. The viewer is not evicted, nothing is sent during the backlog, and after the drain exactly one
text and then the newest frame arrive. This failed before the eviction fix.
Screencast retry: the last refused frame is delivered after the drain with no new frame produced.
Retrying stops when the viewer leaves, and a newer frame replaces the pending one.
Wider run: 627 files and 5712 tests pass across the rpc, browser, screencast, runtime,
ws-outbound-queue and remote-runtime suites. tsc (node), oxlint, oxfmt and the changed-code quality gate
are clean.
Notes
Queued bytes are capped at 128 MiB / 16,384 frames per process, and 64 MiB / 4,096 frames per socket.
the channel.