🚑 report failing url instead of crashing on download errors#8
Conversation
|
Pushed 721287a addressing all review threads (Error + cause model, hierarchy print, dropped the abort guard). Ran the recompiled binary against the live site ( |
|
Sounds good, although should this be an option? Basically whether we fail fast or not? |
A thrown exception during a download (e.g. a gzip/transport decode error, an HTML parse error, or a filesystem write error) escaped uncaught and crashed the whole run with a raw stack trace that gave no indication of which url was being fetched. Route thrown exceptions into the existing collected-error path so the run keeps going, writes every page/asset that succeeded, reports each failing url with its referrer and the underlying reason, and exits non-zero at the end. Also attach the failing url to sitemap read/parse errors.
Address review: carry a real Error (not a string) on failed downloads, wrap the underlying error as `cause`, and print the full cause hierarchy in the summary. Drop the unreachable signal.aborted re-throw guard — effection unwinds a halt via generator return, so cancellation never reaches this catch.
721287a to
73b8d04
Compare
|
Good call — added in 73b8d04. There's now a Also rebased the branch onto |
By default a failed download is collected and reported at the end while the run continues. Add a --strict flag, threaded through useStaticalizer, that re-throws on the first download failure so the run aborts.
73b8d04 to
d82bf18
Compare
|
Addressed the review in d82bf18 — I'd over-engineered the fail-fast path. Rundown:
One thing worth your call on the UX. Throwing from inside the download task can't be caught downstream to pretty-print it: the task buffer's
Making the CLI print the nice hierarchy in strict mode would mean reintroducing a result-based mechanism (roughly the thing you just told me to delete), so I left it as the clean crash. Happy to add the formatted variant if you'd rather have consistent output — your call. |
Motivation
The frontside.com deploy workflow fails at the Staticalize step with:
The message gives no indication of which URL was being downloaded, so it is impossible to tell which page on the site is misbehaving.
The download operation only routed non-2xx responses into the graceful, collected error path. Any thrown exception — a gzip/transport decode error, an HTML parse error, or a filesystem write error — escaped uncaught, killed the whole run, and printed a raw stack trace with no
source/referrercontext, even though both are in scope at the throw site.Approach
downloader.ts: wrap the download body intry/catch. On a thrown error (re-throwing if the run was aborted), return{ ok: false, url, referrer, error }so it flows into the existing collected-error mechanism instead of crashing. The run keeps going, every page/asset that succeeds is still written, and it exits non-zero at the end. The non-2xx branch also now carries anerrormessage for consistency.progress.ts/main.ts: thread the optionalerrorthroughDownloadErrorand print it in the failed-downloads summary.staticalize.ts: attach the sitemap URL to read/parse failures of/sitemap.xml.test/staticalize.test.ts: new case serving a page that advertisesContent-Encoding: gzipwith a non-gzip body — asserts the run does not crash, healthy pages are still written, and the bad page is skipped. Verified this test reproduces the exactInvalid gzip headercrash without the fix.Example output now:
Bumps
deno.jsonversion0.2.2→0.2.6(stale field; latest release is v0.2.5) for the follow-upv0.2.6release that frontside.com's deploy workflow will consume.