fix: support backup and restore of large projects - #491
Merged
Conversation
Building the whole export as a single JSON string via JSON.stringify (and rebuilding it on import) hit V8's ~512MB string cap once assets are inlined as base64, throwing "Invalid string length". Serialize the export as concatenated Buffer chunks and parse the import by byte-scanning the decompressed buffer, parsing the manifest, each row, and each asset file from small slices. Output stays byte-identical to JSON.stringify, so existing backups still restore.
tristan-mouchet
requested review from
liamwalder,
lunenas and
ysamcode
as code owners
August 7, 2026 08:06
Closed
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
Backing up or restoring a project with enough inlined assets failed with
Invalid string length. The export was built as a singleJSON.stringifystring (and rebuilt viaJSON.parseon restore), which exceeds V8's ~512MB max string length once asset files are embedded as base64. This fixes both directions so large projects can be backed up and restored, including password-encrypted backups.Changes
Bufferchunks (serializeExportToBuffer), stringifying the manifest, each table row, and each asset file individually — aBufferisn't bound by the string cap. Output is byte-identical toJSON.stringify.parseExportFromBuffer),JSON.parse-ing the manifest, each row, and each file from small slices, so no large string is ever built. Safe because JSON structural characters are ASCII and don't collide with UTF-8 content..ycodefiles remain compatible (standard JSON, key-order/whitespace agnostic); invalid files still surfaceInvalid backup file.Reported in #490.
Test plan
.ycodedownloads withoutInvalid string lengthInvalid backup fileerror