Skip to content

fix(engine): probe header limit, retries with progress, keep chunk-0 200 - #16

Merged
troke12 merged 3 commits into
mainfrom
engine-probe-timeout-retry
Oct 19, 2026
Merged

troke12 merged 3 commits into
mainfrom
engine-probe-timeout-retry

Conversation

@troke12

@troke12 troke12 commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Three follow-ups left open after the engine PRs (#1, #7, #10), before 0.5.0.

Changes

  1. Probe header limit (6dad126): Inspect had no limit, so a server that accepted the probe and never answered held a new download at the start until it was paused. The probe now uses the same header limit as a transfer (5 min, or the download's headerTimeout), and the error says "no response from the server within …". On resume the probe stays non-fatal.
  2. Retries that made progress (4508d9c): fetchWithRetry counted every failed attempt, so a connection that brought some bytes and then stalled, again and again, failed after 8 stalls even though each one moved the chunk. An attempt that stored bytes now resets the count and the backoff. Attempts with no progress still run out. This is the same hole fix(engine): retry when a connection closes early #7 closed for short bodies, on the stall path.
  3. Chunk 0 whole-file 200 (this PR's last commit): when the chunk at byte 0 gets the whole file as a 200, its body is already at the right offset. It is kept and runs to the end on one connection (takeWholeFile), instead of being dropped and the remainder asked for again. Other chunks are retired; their workers stop at their next write or request.

Test plan

  • go test ./..., go test -race ./internal/engine, and the affected tests ×5 with -race
  • TestProbeHeaderTimeout: fails (stuck until the test deadline) with an unbounded probe.
  • TestResumeProbeHangDoesNotBlock: a hung resume probe does not block the resume.
  • TestStallsWithProgressDoNotRunOut: more stalls than MaxRetries, each after 4 KiB, completes. Fails without the reset.
  • TestStallsWithoutProgressRunOut: exactly MaxRetries transfers, then an error.
  • TestChunkZeroWholeFileIsKept: one transfer request. Fails (2 requests) without takeWholeFile.
  • TestTakeWholeFileRetiresTheRest, and TestSubrangeOKFallsBackToOneConnection updated to expect the single request.

✨ Generated with Claude Code (claude.ai/claude-code) 2.1.303 (claude-opus-5-5)

I Made Ocy Darma Putra added 3 commits October 19, 2026 10:57
Inspect used client.Do with no limit: a server that accepted the probe
and never answered held a new download at the start until it was paused.
The probe now gets the same header limit as a transfer (DefaultHeaderTimeout,
or the download's headerTimeout), and a timeout is reported as a stall
("no response from the server within ..."). On resume the probe stays
non-fatal, so a hung check lets the resume go on as before.

✨ Generated with Claude Code (claude.ai/claude-code) 2.1.303 (claude-opus-5-5)
fetchWithRetry counted every failed attempt against MaxRetries, so a
connection that brought some bytes and then stalled, again and again,
failed after 8 stalls although each one moved the chunk forward: the
same hole #7 closed for short bodies, on the stall path. An attempt
that stored bytes now restarts the count and the backoff; attempts with
no progress still run out (TestStallsWithoutProgressRunOut).

✨ Generated with Claude Code (claude.ai/claude-code) 2.1.303 (claude-opus-5-5)
When the chunk that starts at byte 0 got the whole file as a 200, its
body was dropped (errIgnoredRange), the pass stopped, and the remainder
was asked for again on one connection, though that body was already at
the right offset. takeWholeFile now makes that chunk the only one,
running to the end of the file on this connection. The other chunks are
retired: their connections stop at their next write (the plan changes)
or their next request. If another connection put the download on one
connection first, this one stops as before.

TestChunkZeroWholeFileIsKept: one transfer request instead of two.
TestSubrangeOKFallsBackToOneConnection now expects that single request.

✨ Generated with Claude Code (claude.ai/claude-code) 2.1.303 (claude-opus-5-5)
@troke12
troke12 merged commit d74f957 into main Oct 19, 2026
5 checks passed
@troke12
troke12 deleted the engine-probe-timeout-retry branch October 19, 2026 04:07
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