fix: streaming Export leaves a recoverable .partial file on cancel/error#114
Merged
Merged
Conversation
…ror (#105) writable.abort() on Chrome's File System Access API leaves a hidden, 0-byte .crswap swap file behind and never materializes the visible target — so a cancelled or mid-stream-failed export recovered nothing. streamToFile now close()s the writable instead (finalizing whatever bytes were already committed) and renames it in place to <name>.partial via FileSystemFileHandle.move() (Chrome 110+), falling back to the plain, non-renamed file when move() is unsupported or itself fails. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…tial-artifact-105 # Conflicts: # CHANGELOG.md
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.
What & why
Closes #105.
Cancelling an export (or hitting a mid-stream server error) called
writable.abort()on the File System Access API'sFileSystemWritableFileStream. On Chrome this leaves a hidden, 0-byte.crswapswap file behind and never materializes the visible target the user picked — so a cancelled/failed export recovered neither the target file nor any partial data, just an invisible orphan.streamToFile(src/ui/app.js) nowclose()s the writable in the catch path instead — finalizing whatever bytes were already committed under the target handle — then renames it in place to<name>.partialviaFileSystemFileHandle.move()(Chrome 110+), so a cancelled/failed export leaves a clearly-labeled, inspectable partial artifact. Falls back to leaving the plain, non-renamed file when.move()is unsupported, or if the rename itself throws (e.g. a name collision) — best-effort, never blocks surfacing the original error.Applies uniformly to both export paths that share
streamToFile: the single-file export (exportDirect) and the per-statement script export (exportScript).Checklist
npm testpasses (the per-file coverage gate is non-negotiable)npm run buildsucceeds (single-filedist/sql.html)src/core/, network insrc/net/(injected fetch), DOM insrc/ui/CHANGELOG.md([Unreleased]) updated if behavior or the deployed surface changedinboxfix, not on the Roadmap to 1.0.0 #68 build order.Test plan
npm test— 1281/1281 passing, all per-file coverage gates hold (app.js: 100/96.24/92.01/100 — within its documented floor)npm run build—dist/sql.htmlbuilds cleanabort-not-called assertions) were appliedFileSystemWritableFileStream/FileSystemFileHandle🤖 Generated with Claude Code