fix: abort scan-from-url downloads on cancel; cap download size (#136)#162
Merged
Conversation
ecb84bb to
dfd2fe8
Compare
Cancelling a scan-from-url job now aborts the in-flight download via an AbortController wired from cancelJob through downloadToTemp (fetch + stream pipeline). Adds a 2 GB MAX_DOWNLOAD_BYTES cap (content-length check up front, byte-counting Transform during streaming) and cleans up the partial temp dir on any failure. Closes #136. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BxexPASV1UbMj8ede48RLu https://claude.ai/code/session_01BxexPASV1UbMj8ede48RLu
dfd2fe8 to
0a3c167
Compare
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.
Summary
Closes #136. Cancelling a scan-from-url job didn't abort the in-flight download —
runFetchonly checked the cancel flag afterdownloadToTempresolved, so a large tarball kept streaming to disk. There was also no download size cap or partial-file cleanup.Changes
src/remoteFetch.js:downloadToTemp(url, { signal })— theAbortSignalreaches bothfetchand the streampipeline;MAX_DOWNLOAD_BYTES(2 GB) enforced via content-length and a byte-counting Transform (covers chunked bodies with no content-length); on any failure the temp dir is removed before rethrowing; aborts normalize todownload cancelled.src/scanJobs.js: each fetch job carries anAbortController;cancelJobaborts it immediately; a cancel-triggered abort finishes the job ascancelled, notfailed.tests/node/remoteFetch.test.js: new suite — abort mid-download rejects withdownload cancelledand leaks no temp dir; over-cap content-length rejects withdownload too large.Test plan
npm test→ 155/155 (new tests included, suite runs in ~1 s).Note
Branch predates the P0 merges that touched
src/scanJobs.js(#153/#154) — I'll rebase it onto main once the P0 queue completes.Not enabling auto-merge.
Generated by Claude Code