Skip to content

AVIOReader reconnect loop under sustained 429: seek-driven reconnects reset the give-up streak, so a rate-limited origin never fails cleanly #71

Closed

Description

What happened?

What happened?
When an origin rate-limits (returns 429 on essentially every request), AVIOReader keeps reconnecting instead of backing off and failing cleanly. Two interacting causes: (1) the 429 responses carry no Retry-After, so backoffBeforeReconnect gets retryAfter=0; (2) random-access parse reads call seekReconnect, which sets unproductiveReconnects = 0 — because the parser alternates seeks, the give-up streak is reset before it reaches the cap in recordReconnectAndShouldGiveUp, so the reader loops indefinitely (gen=N climbs) rather than surfacing a clean failure. Expected: on 429/503, honor backoff and give up cleanly after a bounded number of attempts.

Steps to reproduce

Steps to reproduce

  1. Stream a remote file from an origin that is actively rate-limiting (or generate the load by opening several large range-heavy files in quick succession against the same host).
  2. engine.load(url:).
  3. Watch the [AVIOReader] logs: status=429, reconnecting (streak=…) and chunk fetch got HTTP 429, with gen=N climbing and no clean termination.

AetherEngine version or commit SHA

3.13.2

Host app

Custom / my own integration

Platform

macOS

OS version

27 beta

Device / chip

m2 / a9 pro

Playback path

Native AVPlayer

Source media (for playback bugs)

Any remote HTTP(S) source; IO-layer failure independent of container/codec. Most visible on a non-faststart / coarsely-interleaved MP4 (more parse seeks → more churn).

Error codes / log lines

[AVIOReader] chunk fetch got HTTP 429 at offset 0 (cached URL, will retry source)
[AVIOReader] chunk fetch got HTTP 429 at offset 0
[AVIOReader] Persistent conn ended at offset … status=429, reconnecting (streak=1 retryAfter=0.0s)
[AVIOReader] Persistent conn ended at offset … status=429, reconnecting (streak=2 retryAfter=0.0s)
[AVIOReader] Persistent conn start gen=15 offset=…      # gen keeps climbing, no give-up

Anything else

Proposed fix. Track a rate-limit streak that is not reset by seekReconnect; on 429/503 (or a detour/chunk fetch returning 429), apply exponential backoff (honoring Retry-After when present) and bail with a clean error after a small cap, instead of immediately re-seeking. Healthy origins fetch successfully, so the streak stays at zero and normal playback is unaffected.
Why it won't regress normal playback. The new path only engages when fetches are failing with rate-limiting; a successful read resets the streak, so a single transient blip just costs a brief backoff. (Locally I've implemented exactly this in the detour fallback as a stopgap; this issue asks for it in the engine's reconnect machinery generally.)
Related: #69 (detour cache) — this hardens the same reconnect path for the throttled-origin case the cache can't help with.

Activity

  1. ghost added
    bug
    on Jun 26, 2026
  2. superuser404notfound commented on Jun 26, 2026

    @superuser404notfound
    Owner

    Fixed in 4.2.1 (a6f46bf), paired with #69 as you suggested.

    A 429/503 now drives a separate rate-limit streak that is not reset by the seek-driven reconnects and is cleared only by real read progress, so the parse-seek churn can no longer mask a throttled origin. Backoff grows with the streak even when the 429 carries no Retry-After, and the reader gives up cleanly after a bounded number of attempts instead of climbing gen=N forever. A healthy origin reads successfully, keeps the streak at zero, and is unaffected.

    The detour cache from #69 reuses the same streak: a detour fetch that hits a 429 backs off in place and retries the pooled fetch rather than opening a fresh connection, so it cannot re-enter the churn the cache removes.

    Leaving open until you can confirm on 4.2.1.

    Release: https://github.com/superuser404notfound/AetherEngine/releases/tag/4.2.1

  3. ghost closed this as completedon Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions