-
-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FileHandle (from File System Access API) is not serialized unless primary key is not inbound #1236
Comments
Looks like this also works:
|
Seems to me as a browser bug. idb-keyval does not name the primary key either (no inbound key) so they probably don't hit the bug. |
is it possible to solve this bug? i would like to save to indexeddb file handle as value in a doc, eg:
The only way currently is to use idb-keyval, when using Dexie and set the file handle as value, the file handle turns into blank object |
You can use outbound keys also with Dexie. |
No problems on add operations with either an outbound key or a key with an unique index. However, on update operations, the file handle will be lost. To continue with the previous example: async updateName () {
return await db.fileHandles.update(2, { name: 'newName' })
} name will be updated and handle will be an empty object.
Browser : Chrome 91 |
Thanks @nonovd for these details. This is not a browser bug as I thought, but a lack of support for FileSystemFileHandle in cases when Dexie needs to clone objects (which may happen in update calls and some other situations as well). I just added a PR that should fix this #1327. |
Resolved in master. New release on its way. |
Release in dexie 3.1.0-beta.12
|
This is a reproduction of this working scenario using
idb-keyval
: https://glitch.com/edit/#!/filehandle-indexeddb?path=script.js%3A1%3A0With Dexie, using the following code:
This results in a record with
{ fileHandle: {} }
(empty object)However, if I do not name the primary key, it serializes the object properly:
Result:
{ fileHandle: FileSystemFileHandle... }
Fortunately this workaround is ok for me, but seems like it may be a bug, and certainly something that may trip people up.
The text was updated successfully, but these errors were encountered: