fix(resilience): clean up partial file on skill download failure#24141
Closed
kevinWangSheng wants to merge 2 commits into
Closed
fix(resilience): clean up partial file on skill download failure#24141kevinWangSheng wants to merge 2 commits into
kevinWangSheng wants to merge 2 commits into
Conversation
When pipeline(readable, file) fails during a skill download, the partial file at destPath is left on disk. Wrap the pipeline call in try-catch to destroy the write stream and unlink the partial file before re-throwing. Co-Authored-By: Claude Opus 4.6 <[email protected]>
The yieldMs: 10 parameter causes a race condition on Windows CI where the exec result status is still 'running' instead of 'completed'. Upstream PR openclaw#24070 identified this as a known flaky test. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
This pull request has been automatically marked as stale due to inactivity. |
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
pipeline(readable, file)fails indownloadFile()(src/agents/skills-install-download.ts), the write stream is destroyed by pipeline but the partial file atdestPathis left on disk.pipelinecall in a try-catch that destroys the write stream (if not already destroyed) and unlinks the partial file before re-throwing.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
src/commands/signal-install.tsUser-visible / Behavior Changes
None. The download still fails with the same error; the only difference is that partial files are cleaned up.
Security Impact (required)
NoNoNoNoNoRepro + Verification
Environment
Steps
Expected
destPathis removed after the download failure.Actual (before fix)
Evidence
pipelinerejects on stream error, leaving the file behind. The added try-catch unlinks the file in the error path.Human Verification (required)
pipelinefromnode:stream/promisesrejects and destroys streams on failure but does not unlink files.!file.destroyed).Compatibility / Migration
YesNoNoFailure Recovery (if this breaks)
src/agents/skills-install-download.tsunlinkitself throws unexpectedly (mitigated by.catch(() => {})).Risks and Mitigations
unlinkcould race with another process using the file.downloadFilereturns successfully.Generated with Claude Code
Greptile Summary
Added try-catch around
pipelinecall indownloadFile()to clean up partial files when downloads fail. Whenpipelinerejects due to stream errors (timeout, connection reset), the write stream is destroyed and the partial file atdestPathis unlinked before re-throwing the error.file.destroy()with!file.destroyedcheck sincepipelinealready destroys streams on failure.catch(() => {})onunlinkto silently handle cases where the file doesn't exist yetConfidence Score: 5/5
!file.destroyed, silent catch on unlink), and the fix follows Node.js stream error handling best practices. The change is well-scoped to a single function and maintains backward compatibility.Last reviewed commit: e480afd