Retire the last URLSession streaming reader: /stream.avcc over a raw socket - #387
Merged
Conversation
…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
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.
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.avcctest reader) was the last consumer onURLSession.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-requiredbazelgate, 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
RawHTTPgains a streaming sibling tosample():stream(port:path:deadline:onConnected:consume:), built on a sharedopenAndReadHeadextracted fromsample. Raw blocking socket,SO_RCVTIMEOper read + a whole-read deadline from one clock.onConnectedfires 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.readAVCCTagsusesstream, keeping its exact length-prefixed envelope parse and the octet-stream content-type assertion (now read from the returned head text).boundedReadis deleted (it existed only to work around AsyncBytes being uncancellable). Net −38 lines./controlPOSTs keepURLSession— not a streaming body, never implicated. No URLSession streaming consumers remain.Verification
sample()) across--nocache_test_resultsruns; full local suite 11/11 green; lint clean.onConnectedkeyframe 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