Repository navigation
fix(core): store assets as raw bytes instead of File objects in Index… - #912
DoudouDoudouk wants to merge 3 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 |
Aymericr
left a comment
There was a problem hiding this comment.
Nice fix, @DoudouDoudouk. The byte record plus the legacy Blob read path is the right approach, and the tests cover both. One small thing before merge: the old /** Save a file to IndexedDB and return a custom protocol URL */ JSDoc is now duplicated and orphaned above the StoredAssetRecord docblock. Please delete that copy and rebase onto current main. CI is also waiting on maintainer approval for this fork, and I'll merge once it's green.
…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
Touches client-side asset upload/load used across the editor; behavior change is backward compatible but affects all paths that call
saveAsset/loadAssetUrl.Overview
IndexedDB asset persistence now writes a versioned
{ bytes, type }record instead of storing theFiledirectly, fixing failures on engines (e.g. WebKit) that rejectFile/Blobvalues in IndexedDB.loadAssetUrlrebuilds aBlobfrom that record via new helpers, keeps loading olderFile/Blobentries, and returnsnullwith a warning when the stored value cannot be turned into a blob—avoiding throws fromURL.createObjectURL. Tests cover the new on-disk shape, legacy records, and broken data.Reviewed by Cursor Bugbot for commit e186799. Bugbot is set up for automated code reviews on this repo. Configure here.