I'm trying to store data at firestore collection but getting this error again and again unable to store data on my messages collection.
@firebase/firestore: Firestore (10.12.3): WebChannelConnection RPC 'Write' stream 0x401c795e transport errored
await addDoc(collection(db, "messages"), {
text: value,
name: username,
createdAt: serverTimestamp(),
uid
})
I want to store messages data to firestore
For me the error occurred because I created a database in Firestone trough the google console with a custom name instead of (default).
I fixed the issue by doing:
One way was explained on Github.
For what worked was also initializing it using experimentalForceLongPolling:
export const db = initializeFirestore(app, {
experimentalForceLongPolling: true
})
instead of this:
export const db = getFirestore(app);
Here is how I fixed It
Ran into the same issue today while working on a client's project. After hours of debugging, I discovered the root cause: the Firestore database was not using the default name.
If you created your Firestore database with a custom name (instead of the default "default"), and you're not explicitly specifying it in your code, you may encounter this error/warning when trying to access Firestore.
✅ Solution:
You need to either create a default database named "default" in the Firebase console OR Explicitly specify the custom database name in your getFirestore call:
const app = initializeApp(firebaseConfig);
const db = getFirestore(app, 'yourCustomDatabaseName');
Make sure to replace 'yourCustomDatabaseName' with the actual name you used when setting up your Firestore database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With