Skip to content
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

Unable to store back an object retrieved from IndexedDB #31130

Open
tomyeh opened this issue Oct 18, 2017 · 0 comments
Open

Unable to store back an object retrieved from IndexedDB #31130

tomyeh opened this issue Oct 18, 2017 · 0 comments
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-libraries Issues impacting dart:html, etc., libraries

Comments

@tomyeh
Copy link

tomyeh commented Oct 18, 2017

If the data is a list and it contains a map, we can't store back the data if it was retrieved previously.

Test Code:

main() async {
  final db = await window.indexedDB.open("test", version: 1,
      onUpgradeNeeded: (e) {
        final Database db = e.target.result;
        if (!db.objectStoreNames.contains("test"))
          db.createObjectStore("test", keyPath: "id");
      });

  final os = db.transaction("test", "readwrite")
  .objectStore("test");

  await os.put({"id": "foo", "data": [{"f": 123}]}); //OK
  final val = await os.getObject("foo");
  await os.put(val); //FAILED
  print("DONE");
}

It threw an exception:

DataCloneError: Failed to execute 'put' on 'IDBObjectStore': An object could not be cloned.
#0      Blink_JsNative_DomException.callMethod (dart:_blink:38965)
#1      BlinkIDBObjectStore.put_Callback_1_ (dart:_blink:14724)
#2      ObjectStore._put (dart:indexed_db:1127)
#3      ObjectStore.put (dart:indexed_db:924)
...

Dart SDK: 1.24.2

@kasperl kasperl added the web-libraries Issues impacting dart:html, etc., libraries label Oct 25, 2017
@vsmenon vsmenon added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label Jul 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-libraries Issues impacting dart:html, etc., libraries
Projects
None yet
Development

No branches or pull requests

3 participants