Repository navigation
fix(pipeline): retry a raw file whose download drops part-way - #3
Merged
Merged
Conversation
The scheduled EIA-930 check failed on 2026-11-10 because the PJM workbook's download was dropped: nothing retried it, so the file was never read to the end, its SHA-256 stayed unknown, and the whole refresh failed while the previous version stayed live. EIA rebuilds a workbook per balancing authority every day and the largest are over 100 MB, so one dropped socket in sixty-nine downloads lost the month's refresh. Raw files now go through fetchRaw, which tries three times with a growing pause. The body is consumed inside the attempt, so a failure part-way through a 100 MB download is retried from the start rather than leaving a half-built hash. A 4xx other than 408 or 429 is the publisher's own answer, not a blip: it comes back unread at once and every caller reports it exactly as before, so no failure message or status changes. Opening a streamed file is retried too, though a drop once its bytes are flowing still fails the run, since the hash is part-built by then and the read cannot restart. Closes #2. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Status: LGTM — ready to merge. Closes #2.
What was wrong
The scheduled EIA-930 check failed on 2026-11-10 with:
fetch failedis undici's message for a connection that never completed. Nothing in the pipeline retried a raw-file download —pipeline/run.mjshad three barefetchcalls and no retry anywhere in the repo. So the first dropped socket ended the run:xlsxOfnever finished reading the body,r.sha256stayednull, and the integrity check atrun.mjs:309failed the whole refresh.That is an expensive way to lose a month. EIA rebuilds a workbook for every balancing authority daily and the largest are over 100 MB; the run downloads 69 of them in a row. One blip in 69 large downloads lost the refresh, and the previous version stayed live.
How it was fixed
Raw files now go through
fetchRaw, which tries three times with a growing pause (2s, then 4s).The important detail is where the body is read.
readis called inside the attempt, so a failure part-way through a 100 MB download is retried from the start of the download rather than leaving a half-built hash. Retrying only the connection would not have been enough for a file this size.What does not change:
HTTP 503andHTTP 404messages, and the thrown network error, are byte-for-byte what they were; only the number of attempts before them changed.linesOf, used by EAGLE-I's yearly CSVs) is retried, but a drop once bytes are flowing still fails the run — the hash is part-built by then and the read cannot restart. This is called out in the comment rather than papered over.Proof it works
verify/tests/pipeline/raw-fetch.test.mjs, 7 tests, all passing:TypeError: fetch failedfrom the issue, twice, then successHTTP 503calls === 1— no pointless retries on a real answerlinesOf[100, 200]— a briefly overloaded publisher is not hammeredFull unit suite passes.
Notes / nits
attempts,delayMs,fetch, andsleepare injectable only so the tests do not sleep for real. This matches howlinkCheckalready takes{ fetch, host, root, now }.docs/own-implementations.mdentry is needed — it is a helper insiderun.mjs, used only there.🤖 Generated with Claude Code