flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [cloud_firestore_web]: Uncaught (in promise) unimplemented when using loadBundle

Open rohansohonee opened this issue 3 years ago • 9 comments

Bug report

When using the loadBundle on web, the browser dev tool's console window displays the following error message:

Uncaught (in promise) unimplemented
  | loadBundle | @ | firestore.dart:114
  | loadBundle | @ | cloud_firestore_web.dart:171
  | loadBundle | @ | firestore.dart:98

Expected behavior

Should not throw any errors.

Additional Context

There are no errors shown in IDE(Android Studio) console. The errors are only being shown in the browsers console log.

Flutter doctor

Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.2, on macOS 12.4 21F79 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.69.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!

Flutter dependencies

dependencies:
 cloud_firestore: 3.2.1
 firebase_core: 1.19.1

dependency_overrides:
  firebase_core_web: 1.6.6
  cloud_firestore_web: 2.6.19

Only depending on firebase dependencies to produce this issue. Added certain overrides because of firebase_core_web issue with version 1.7.0 as mentioned here: https://github.com/firebase/flutterfire/issues/9132

rohansohonee avatar Jul 18 '22 18:07 rohansohonee

@rohansohonee This looks similar to https://github.com/firebase/flutterfire/issues/7722. In your case, does it occur locally or when you deploy to server ?

darshankawar avatar Jul 19 '22 11:07 darshankawar

@darshankawar it occurs both locally and on deployed server.

In my error I do not have the "invalid argument" being shown as described in the issue you referenced.

rohansohonee avatar Jul 19 '22 11:07 rohansohonee

Thanks for the update. Can you provide minimal reproducible code sample that triggers this error ?

darshankawar avatar Jul 20 '22 10:07 darshankawar

@darshankawar it is producible with the example https://firebase.flutter.dev/docs/firestore/usage/#data-bundles

rohansohonee avatar Jul 20 '22 15:07 rohansohonee

Looking at the example, the data bundle is being converted from string to Uint8List instance:

// Convert the 'bundle.txt' string in the response to an Uint8List instance.
Uint8List buffer = Uint8List.fromList(response.body.codeUnits);

Can you provide response.body in properly formatted text ?

I am guessing the error could be due to the way web js sdk is handling the conversion. I see a similar issue in their repo: https://github.com/firebase/firebase-js-sdk/issues/5838

darshankawar avatar Jul 21 '22 08:07 darshankawar

@darshankawar It can be produced from the sample I provided in #9114

So you can inspect the response.

rohansohonee avatar Jul 21 '22 08:07 rohansohonee

Thanks. Using the code sample provided in linked issue, I am able to replicate the error mentioned.

A similar issue was raised upstream : https://github.com/firebase/firebase-js-sdk/issues/5838

Also related : https://github.com/firebase/flutterfire/issues/7722

darshankawar avatar Jul 22 '22 11:07 darshankawar

Also faced this issue after upgrading to JS v9

firebase_core: 1.20.0
cloud_firestore: 3.4.1

rohansohonee avatar Jul 28 '22 11:07 rohansohonee

I've just tested this, and the exception does occur. However, it still bundles the data.

I've also tested this using a purely JS implementation like so:

import { initializeApp } from 'firebase/app';
import { getFirestore, loadBundle } from 'firebase/firestore';

const firebaseConfig = {
  apiKey: "AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0",
  authDomain: "react-native-firebase-testing.firebaseapp.com",
  databaseURL: "https://react-native-firebase-testing.firebaseio.com",
  projectId: "react-native-firebase-testing",
  storageBucket: "react-native-firebase-testing.appspot.com",
  messagingSenderId: "448618578101",
  appId: "1:448618578101:web:f9978594cf6fc210ac3efc",
  measurementId: "G-9DTMXSP12B"
}

var app = initializeApp(firebaseConfig);

var firestore = getFirestore(app);

async function loadBundleFunc(){
  // bundle I've created and hosted on a local node server:
  var response = await fetch('http://localhost:3000/bundle');

  var data = await response.arrayBuffer();
  var loadBundleTask = await loadBundle(firestore, data);
  console.log('loadBundleTask', loadBundleTask); // loadBundleTask {taskState: 'Success', documentsLoaded: 3, bytesLoaded: 1465, totalDocuments: 3, totalBytes: '1465'}
}

loadBundleFunc();

and I still got that exception in my browser:

Screenshot 2022-07-28 at 14 17 00

I believe this error is coming from the firebase-js-sdk, and I would encourage you to create an issue on their repository here.

russellwheatley avatar Jul 28 '22 13:07 russellwheatley

This issue has now been fixed upstream in the native Firebase web JS SDK. See here: https://github.com/firebase/firebase-js-sdk/issues/5838

russellwheatley avatar Dec 27 '23 12:12 russellwheatley