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

DataCloneError: BlobURLs are not yet supported #2257

Open
stx opened this issue Jan 8, 2023 · 2 comments
Open

DataCloneError: BlobURLs are not yet supported #2257

stx opened this issue Jan 8, 2023 · 2 comments

Comments

@stx
Copy link

stx commented Jan 8, 2023

Using Flutter Web (latest stable everything), we occasionally see this error and have no idea why, because we're not inserting URLs. Seen on Safari 16.1. Is this something that Drift is doing internally?

minified:to: DataCloneError: Failed to store record in an IDBObjectStore: BlobURLs are not yet supported.
  at put@[native code](unparsed)
  at A.Rw.prototype.aQr(org-dartlang-sdk:///lib/indexed_db/dart2js/indexed_db_dart2js.dart:962:14)
  at A.Rw.prototype.b8a(org-dartlang-sdk:///lib/indexed_db/dart2js/indexed_db_dart2js.dart:790:19)
  at $async$ur(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/drift-2.4.2/lib/src/web/storage.dart:217:11)
  at A.i(org-dartlang-sdk:///lib/_internal/js_runtime/lib/async_patch.dart:317:19)
  at A.bnn.prototype.$2(org-dartlang-sdk:///lib/_internal/js_runtime/lib/async_patch.dart:342:23)
  at A.l(org-dartlang-sdk:///lib/_internal/js_runtime/lib/async_patch.dart:247:3)
  at _IndexedDbStorage.open.akb.prototype.apM(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/drift-2.4.2/lib/src/web/storage.dart:213:11)
  at _IndexedDbStorage.open.akb.prototype.ur(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/drift-2.4.2/lib/src/web/storage.dart:213:11)
  at $async$y7(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/drift-2.4.2/lib/src/web/web_db.dart:244:13)
  at A.i(org-dartlang-sdk:///lib/_internal/js_runtime/lib/async_patch.dart:317:19)
  at A.bnn.prototype.$2(org-dartlang-sdk:///lib/_internal/js_runtime/lib/async_patch.dart:342:23)
  at A.l(org-dartlang-sdk:///lib/_internal/js_runtime/lib/async_patch.dart:247:3)
  at A.bk_.prototype.y7(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/drift-2.4.2/lib/src/web/web_db.dart:243:5)
  at A.bk_.prototype.sahH(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/drift-2.4.2/lib/src/web/web_db.dart:96:7)
  at A.a_7.prototype.a3n(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/drift-2.4.2/lib/src/runtime/executor/helpers/engines.dart:270:11)
  at $async$Aj(../../../../programs/flutter_3_3_10/.pub-cache/hosted/pub.dartlang.org/drift-2.4.2/lib/src/runtime/executor/helpers/engines.dart:248:5)
  at A.i(org-dartlang-sdk:///lib/_internal/js_runtime/lib/async_patch.dart:317:19)
  at A.bnn.prototype.$2(org-dartlang-sdk:///lib/_internal/js_runtime/lib/async_patch.dart:342:23)
  at _awaitOnObject.<anonymous function>.blI.prototype.$1(org-dartlang-sdk:///lib/_internal/js_runtime/lib/async_patch.dart:293:19)
  at A.bnc(org-dartlang-sdk:///lib/async/zone.dart:1399:46)
  at _CustomZone.runUnary(org-dartlang-sdk:///lib/async/zone.dart:1397:3)
  at A.aij.prototype.qy(org-dartlang-sdk:///lib/async/zone.dart:1299:34)
  at A.b9v.prototype.$0(org-dartlang-sdk:///lib/async/future_impl.dart:112:29)
  at A.JU(org-dartlang-sdk:///lib/async/future_impl.dart:795:13)
  at A.av.prototype.uC(org-dartlang-sdk:///lib/async/future_impl.dart:566:5)
  at A.b9n.prototype.$0(org-dartlang-sdk:///lib/async/future_impl.dart:639:7)
  at A.bna(org-dartlang-sdk:///lib/async/zone.dart:1391:12)
  at _CustomZone.run(org-dartlang-sdk:///lib/async/zone.dart:1382:3)
  at A.aij.prototype.tP(org-dartlang-sdk:///lib/async/zone.dart:1292:34)
  at A.aij.prototype.tQ(org-dartlang-sdk:///lib/async/zone.dart:1201:7)
  at _CustomZone.bindCallbackGuarded.<anonymous function>.b5W.prototype.$0(org-dartlang-sdk:///lib/async/zone.dart:1241:23)
  at A.c_m(org-dartlang-sdk:///lib/async/schedule_microtask.dart:40:12)
  at A.c04(org-dartlang-sdk:///lib/async/schedule_microtask.dart:49:5)
  at A.b2a.prototype.$1(org-dartlang-sdk:///lib/_internal/js_runtime/lib/async_patch.dart:49:10)
  at A.c33(org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_helper.dart:1834:14)
  at A.lo(org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_helper.dart:1866:1)
@simolus3
Copy link
Owner

simolus3 commented Jan 9, 2023

At the moment, we store data in IndexedDB like this:

@override
Future<void> store(Uint8List data) async {
final transaction =
_database.transactionStore(_objectStoreName, 'readwrite');
final store = transaction.objectStore(_objectStoreName);
await store.put(Blob([data]), name);
await transaction.completed;
}

I suspect that Safari doesn't like Blobs. IndexedDB should support storing Uint8Lists directly, but unfortunately the Dart SDK is doing a manual list copy when storing any List in there. We can avoid this by calling the native method directly. I have done this on the avoid-storing-blobs branch, could you try it out and see if that fixes the problem (if you have a way to reproduce this somewhat reliably?):

dependency_overrides:
  drift:
    git:
      url: https://github.com/simolus3/drift.git
      ref: avoid-storing-blobs
      path: drift

But it's pretty weird that this happens occasionally. If blobs aren't supported, why doesn't it fail every time 😕?

@jetpeter
Copy link

The reproduce the error try Safari with a private window. I think it is that Safari does not support blobs for some reason in Private Browsing.

Note Im using the old index db method of opening the database. Not sure what happens with the web worker.

final executor = LazyDatabase(() async {
    return WebDatabase.withStorage(await DriftWebStorage.indexedDbIfSupported('database_name'));
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants