fix(core): store assets as raw bytes instead of File objects in Index… - #912
Open
DoudouDoudouk wants to merge 2 commits into
Open
DoudouDoudouk wants to merge 2 commits into
DoudouDoudouk wants to merge 2 commits into
Conversation
…edDB
saveAsset put the File itself into IndexedDB. Not every engine accepts
File/Blob records (WebKit rejects the write), so every upload that goes
through saveAsset failed there with no fallback.
Store { assetVersion: 1, bytes, type } instead, which uses the portable
structured-clone path. loadAssetUrl rebuilds a Blob from that record,
still reads File/Blob records written before this change, and returns
null for an unreadable record instead of throwing inside createObjectURL.
|
I hit an error while handling your request (Model unavailable on AI Gateway free tier: Free tier users do not have access to this model. Upgrade to paid credits at https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Fmodal%3Dtop-up for unrestricted…). Please try again, rephrase, or reach out if it keeps failing. Error id: 550823bd-bd72-4994-9e26-6cad61eb3629 |
This branch has not been deployed
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.
…edDB
saveAsset put the File itself into IndexedDB. Not every engine accepts File/Blob records (WebKit rejects the write), so every upload that goes through saveAsset failed there with no fallback.
Store { assetVersion: 1, bytes, type } instead, which uses the portable structured-clone path. loadAssetUrl rebuilds a Blob from that record, still reads File/Blob records written before this change, and returns null for an unreadable record instead of throwing inside createObjectURL.
What does this PR do?
How to test
Screenshots / screen recording
Checklist
bun devbun checkto verify)mainbranchNote
Medium Risk
Changes how all local asset uploads are persisted and loaded, but behavior stays the same for callers and legacy data is still supported.
Overview
Fixes asset uploads failing on engines (notably WebKit) that reject storing File/Blob values in IndexedDB.
saveAssetnow persists a versioned record{ assetVersion: 1, bytes, type }instead of the File itself, using structured-clone-friendly ArrayBuffer data while preserving MIME type for later blob URLs.loadAssetUrlreconstructs a Blob from that record via a newtoBlobpath, still reads legacy File/Blob entries written before this format, and returnsnull(with a warning) for corrupt or unexpected records instead of blowing up increateObjectURL.Tests cover the new storage shape, backward compatibility, and unreadable-record handling.
Reviewed by Cursor Bugbot for commit f4f96dc. Bugbot is set up for automated code reviews on this repo. Configure here.