dumbmatter / fakeIndexedDB

A pure JS in-memory implementation of the IndexedDB API
Apache License 2.0
562 stars 69 forks source link

DataCloneError: The data being stored could not be cloned by the internal structured cloning algorithm. #85

Closed rwxmad closed 1 year ago

rwxmad commented 1 year ago

I created a test where I check if the Blob object was added to indexeddb , but when I run the test, it fails Test:

import "fake-indexeddb/auto";
import { IndexDBKeyValueBlobStorage } from "./IndexDBKeyValueBlobStorage";

const DB_NAME = "db";
const DB_VERSION = 3;
const STORE_NAME = "test";
const INDEX = "index";

describe("setAsync", () => {
  test("should find record", async () => {
    const db = new IndexDBKeyValueBlobStorage(DB_NAME, DB_VERSION);
    const value = new Blob(
      [JSON.stringify({ name: "test", age: 25 }, null, 2)],
      {
        type: "application/json",
      }
    );

    const result = await db.setAsync(STORE_NAME, INDEX, value);
  });
});

Error: Screenshot 2023-08-15 at 14 41 03

dumbmatter commented 1 year ago

What version of Node.js are you using? Blobs should work, but maybe only in Node 18 or newer https://github.com/dumbmatter/fakeIndexedDB/issues/56#issuecomment-1236166287

If you're on Node 18+ and it's still not working, can you post a full code example I can run to see the problem myself?

rwxmad commented 1 year ago

What version of Node.js are you using? Blobs should work, but maybe only in Node 18 or newer #56 (comment)

If you're on Node 18+ and it's still not working, can you post a full code example I can run to see the problem myself?

Аfter updating nodejs the error is gone, thanks a lot