Repository navigation
fix(io): fail closed when an HLS playlist is misrouted onto the raw live path (#140) - #144
Merged
superuser404notfound merged 1 commit intoJul 19, 2026
Conversation
…ive path (#140) load(url: m3u8, options: LoadOptions(isLive: true)) without nativeRemoteHLS routes the playlist URL onto the raw-byte live reader (AVIOReader). A live origin serves the finite #EXTM3U body at HTTP 200 and closes the connection; the endless-feed reader read that as a dropped live stream and reconnected, re-fetching the same body forever. Those reconnects looked productive (a full body at 200, and every find_stream_info probe seek reset the unproductive streak via seekReconnect), so the #71 give-up counters never tripped, avformat_open_input never returned, and load() sat at .loading with no terminal state (reporter: 262 reconnect cycles over 5.75 min). The raw-byte reader now snapshots the first window bytes of a live source and fails closed when they begin with the HLS playlist tag (#EXTM3U, tolerating a UTF-8 BOM and leading whitespace). A raw media container never opens with '#' (TS syncs on 0x47; MP4/MKV open with binary box/EBML markers), so the prefix is an unambiguous misroute. The reader throws before the reconnect loop is ever entered; load() surfaces it as the new typed, catchable AetherEngineError.hlsPlaylistOnRawLivePath with an actionable message pointing the caller at nativeRemoteHLS / HLSLiveIngestReader. Verified end-to-end via a local static-playlist HTTP fixture on the .url + isLive path: pre-fix hung; post-fix terminates in 0.03s with the typed error. Unit tests cover the byte classifier. Full suite: 730 tests pass. Reported by cmcpherson274. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01UgFNKdx4Mq3zgCawKzAa6w
superuser404notfound
deleted the
fix/ae140-hls-playlist-raw-live-misroute
branch
July 19, 2026 13:01
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.
Fixes #140.
Problem
load(url: m3u8, options: LoadOptions(isLive: true))withoutnativeRemoteHLSbypasses both documented HLS entry points (loadRemoteHLS/HLSLiveIngestReader) and routes the playlist URL onto the raw-byte live reader (AVIOReader, endless-feed mode).A live origin serves the finite ~497-byte
#EXTM3Ubody at HTTP 200 and closes the connection. The endless-feed reader read that as a dropped live stream and reconnected, re-fetching the same body forever. The reconnects looked productive (a full body at 200, and everyfind_stream_infoprobe seek reset the unproductive-reconnect streak viaseekReconnect), so the #71 give-up counters never tripped.avformat_open_inputnever returned, andload()sat at.loadingwith no terminal state (reporter observed 262 reconnect cycles over 5.75 min). The raw-TS live path fails closed correctly because a dead TS source returns a real connection error; a healthy static playlist at HTTP 200 slips past every give-up heuristic.Fix
Detect the misroute at the byte source, not in the give-up counters (which are structurally blind to a productive-looking playlist re-serve). After the persistent connection delivers its first window, the reader snapshots the leading bytes and fails closed when they begin with the HLS playlist tag
#EXTM3U(tolerating a UTF-8 BOM and leading whitespace). A raw media container never opens with#(TS syncs on0x47; MP4/MKV open with binary box/EBML markers), so the prefix is an unambiguous signal that an m3u8 was handed to the wrong API. The reader throws before the reconnect loop is entered.load()surfaces it as a new typed, catchableAetherEngineError.hlsPlaylistOnRawLivePath(with an actionableLocalizedErrordescription pointing the caller atnativeRemoteHLS/HLSLiveIngestReader), reusing the existing live fail-closed seam.Verification
.url+isLivemisroute via a local static-playlist HTTP fixture: pre-fix hung; post-fix terminates in 0.03s with the typed error and an actionable.errorstate, no reconnect cycles.#EXTINF, truncated prefix, empty).swift build(Swift 6 complete concurrency) + tvOS Simulator build green.API surface (MINOR)
Adds
public case AetherEngineError.hlsPlaylistOnRawLivePathand aLocalizedErrorconformance onAetherEngineError→ 5.9.0.🤖 Generated with Claude Code