Repository navigation
Conversation
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.
/claim #59
Summary
Fixes #59 ("Database dumps do not work on large databases").
Previously,
dumpDatabaseRouteinsrc/export/dump.tsexecuted an unboundedSELECT * FROM <table>;for every table and concatenated the entire SQL dump into an in-memory string/Blob. On large databases, this exceeded Cloudflare Workers' memory and RPC payload limits.Changes
LIMIT ? OFFSET ?):generateDumpChunksnow fetches rows in configurable batches (default500rows viaDumpDatabaseOptions.batchSize) instead of loading entire tables in a single query.ReadableStream<Uint8Array>): Replaced in-memory string concatenation andBlobbuffering with aReadableStreamusingpull()andTextEncoder, keeping memory usage bounded to a single batch.iterator.return(), and mid-stream query errors propagate viacontroller.error(error)while pre-stream failures continue returning HTTP 500 JSON.sqlite_%system tables fromsqlite_masterqueries.sqlite_masterschema lookup (name=?) and safely quotes non-standard table identifiers.NULL/undefined, booleans (1/0), andUint8Array/ArrayBufferBLOB values (X'...').src/export/dump.test.ts): Added tests covering multi-page batching, exact batch multiples, 1,250-row streaming with default batch size,NULL/boolean/BLOB/special-identifier formatting, mid-stream error propagation, and early stream cancellation.Testing
npx vitest run src/export/— 4 test files passed, 29 tests passed (11/11 insrc/export/dump.test.ts).