Skip to content

fix(net): refresh live HTTP range bounds after async waits - #439

Open
dmytro-yemelianov wants to merge 1 commit into
ja7ad:mainfrom
dmytro-yemelianov:fix/live-http-range-bounds
Open

dmytro-yemelianov wants to merge 1 commit into
ja7ad:mainfrom
dmytro-yemelianov:fix/live-http-range-bounds

Conversation

@dmytro-yemelianov

Copy link
Copy Markdown

A range can shrink while an HTTP fetch is parked in connect, header reading or rate limiting. The fetch can then request the obsolete tail, write/credit bytes beyond its live prefix, or attempt another read after that prefix is already complete.

This change rechecks the watermark after connect/redial and after the last await before each synchronous write. It skips an empty range, stops before an unnecessary body read, and keeps the original on-wire response bound for connection-pool framing. Rate limiting continues to account for consumed body bytes, including bytes subsequently discarded after a shrink. The scheduler policy is unchanged.

Five deterministic regressions cover reduced/empty ranges during connect and stale-pool redial, body bytes coalesced with delayed headers, a completed prefix followed by a failing read, and plain/chunked bodies paused in rate limiting. They also check credited byte offsets and pool eligibility. All five fail on upstream 73bfb796 with the tests added and pass with this fix. Tokio test-util is explicit in the net crate's dev-dependencies so these tests also run independently of workspace feature unification.

Validation on macOS arm64 / Rust 1.98.1:

  • cargo fmt --all -- --check — passed.
  • cargo clippy --locked --all-targets --all-features -- -D warnings — passed.
  • cargo test --locked --release --all-targets --all-features — passed.
  • cargo test --locked --all-targets --all-features — stopped at one unchanged plugin timing test, exec::tests::unix::cancel_kills_the_child, whose 5-second bound expired (1,741 tests had passed, 5 ignored). The same candidate test binary passes that test alone in 0.13 s; clean upstream passes it alone in 0.11 s. Rechecking the entire hya-plugin library passes all 147 tests. The original full-suite failure is retained; this is not a claim that the first debug run was clean.

This PR addresses the reproduced async-boundary cases. It does not make a watermark load and file write atomic with respect to another thread, and it does not claim a general download-speed improvement. Developed with AI assistance; the upstream failures, corrected tests and validation commands were run locally.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant