Open azangru opened 1 month ago
This seems to be because of Node's structuredClone function works. More minimal example:
const file = new File([
'hello world!'
], 'file.txt');
console.log(Object.getPrototypeOf(file));
console.log(Object.getPrototypeOf(structuredClone(file)));
If you run that in Node, you see the 2nd log is just a Blob rather than a File, but if you run it in a web browser then both are Files.
fake-indexeddb internally uses structuredClone from Node, which does work very similar to the web browser version which is used in the IndexedDB spec, but IIRC there are some minor differences and I guess this is one.
Whether this is a bug in Node or it's intended behavior, I'm not sure, I haven't had a chance to investigate further.
This issue in the Node repo suggests that it may be a Node bug.
fake-indexeddb
seems to support the storage of blobs (https://github.com/dumbmatter/fakeIndexedDB/issues/56); however, if one attempts to store aFile
, then the file, when retrieved, will be converted into aBlob
, and part of its information, such as file name, will be lost.Example: