Skip to content

Retire the last URLSession streaming reader: /stream.avcc over a raw socket - #387

Merged
github-actions[bot] merged 1 commit into
mainfrom
avcc-raw-socket
Jul 14, 2026
Merged

Retire the last URLSession streaming reader: /stream.avcc over a raw socket#387
github-actions[bot] merged 1 commit into
mainfrom
avcc-raw-socket

Conversation

@obj-p

@obj-p obj-p commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Follow-up to #350/#375 (no issue of its own — closes the last streaming consumer that shared the flake class). Coordinator-approved after #262 landed.

Why

readAVCCTags (the /stream.avcc test reader) was the last consumer on URLSession.bytes + boundedRead. That's the AsyncBytes-cancellation-trap exposure that produces the -999 face of the #350 class (the -1 buffering face was fixed for MJPEG in PR #375). Under the now-required bazel gate, a latent AsyncBytes trap intermittently reds PRs (it already bit #376's stale branch), so this closes it at the root rather than waiting for a specimen.

Change

  • RawHTTP gains a streaming sibling to sample(): stream(port:path:deadline:onConnected:consume:), built on a shared openAndReadHead extracted from sample. Raw blocking socket, SO_RCVTIMEO per read + a whole-read deadline from one clock. onConnected fires just before the first body bytes (matching the old first-body-byte timing, so the driven drag still forces an IDR after the subscriber registers), and body chunks feed a stop-predicate.
  • readAVCCTags uses stream, keeping its exact length-prefixed envelope parse and the octet-stream content-type assertion (now read from the returned head text).
  • The elaborate continuation-race deadline machinery in boundedRead is deleted (it existed only to work around AsyncBytes being uncancellable). Net −38 lines.
  • One-shot /control POSTs keep URLSession — not a streaming body, never implicated. No URLSession streaming consumers remain.

Verification

  • MCPIntegrationTests 3/3 and PreviewsIOSTests 3/3 (the latter exercises the refactored sample()) across --nocache_test_results runs; full local suite 11/11 green; lint clean.
  • Gates (MEDIUM): /simplify + /code-review medium, both clean — reviewers verified fd lifecycle (no double-close/leak on any path), that the onConnected keyframe timing is preserved (0x01 replay + forced-keyframe arming still land), envelope parse equivalence across chunk boundaries, and Sendable safety.

Proposed review tier: MEDIUM (test-only, but real socket/async logic + a new shared helper; bounded blast radius).

🤖 Generated with Claude Code

https://claude.ai/code/session_01D9tE6iZwyGJcX5Kx9LUnhm

…am reader

The /stream.avcc reader was the last test consumer on URLSession.bytes +
boundedRead — the AsyncBytes-cancellation-trap exposure that produces the
-999 face of the #350 class (the -1 buffering face was fixed for MJPEG in
PR #375). Under the now-required bazel gate a latent AsyncBytes trap
intermittently reds PRs, so close it at the root rather than wait for a
specimen.

RawHTTP gains a streaming sibling to sample(): stream(...) opens the
connection over a raw blocking socket (shared openAndReadHead, extracted
from sample), fires onConnected just before the first body bytes (matching
the old first-body-byte timing so the driven drag still forces an IDR after
the subscriber registers), and feeds body chunks to a stop-predicate under
SO_RCVTIMEO + a whole-read deadline. No URLSession, no AsyncBytes, so
neither the -1 nor the -999 face can occur, and the elaborate
continuation-race deadline machinery in boundedRead is deleted.

readAVCCTags keeps its exact envelope parse and the octet-stream
content-type assertion (now read from the returned head text). No
URLSession streaming consumers remain; the one-shot /control POSTs keep
URLSession (not a streaming body, never implicated).

Verified: MCPIntegrationTests 3/3 and PreviewsIOSTests 3/3 (the latter
exercises the refactored sample()) across no-cache runs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D9tE6iZwyGJcX5Kx9LUnhm
@obj-p
obj-p force-pushed the avcc-raw-socket branch from 04d7f76 to 085b1b7 Compare July 14, 2026 03:13
@obj-p obj-p added the merge Run CI and auto-merge (squash) on success label Jul 14, 2026
@github-actions
github-actions Bot enabled auto-merge (squash) July 14, 2026 03:14
@github-actions
github-actions Bot merged commit 05904df into main Jul 14, 2026
2 checks passed
@obj-p
obj-p deleted the avcc-raw-socket branch July 14, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge Run CI and auto-merge (squash) on success

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant