flutterfire
flutterfire copied to clipboard
🐛 [cloud_firestore_web]: Uncaught (in promise) unimplemented when using loadBundle
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 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 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.
Thanks for the update. Can you provide minimal reproducible code sample that triggers this error ?
@darshankawar it is producible with the example https://firebase.flutter.dev/docs/firestore/usage/#data-bundles
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 It can be produced from the sample I provided in #9114
So you can inspect the response.
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
Also faced this issue after upgrading to JS v9
firebase_core: 1.20.0
cloud_firestore: 3.4.1
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:
I believe this error is coming from the firebase-js-sdk, and I would encourage you to create an issue on their repository here.
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