Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@firebase/firestore: Firestore (10.12.3): WebChannelConnection RPC 'Write' stream 0x401c795e transport errored

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

like image 996
Aniket Bhosale Avatar asked Jan 22 '26 09:01

Aniket Bhosale


2 Answers

Okay so for everyone still struggling:

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:

  1. Deleting database with custom name
  2. Deleting prebuilt (default) database because the database-mode was set to Datastore-Mode and not Native
  3. Creating a new database with the name "(default)", and setting the mode to Native-Mode

If this isn't your case:

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);
like image 167
venvic Avatar answered Jan 27 '26 00:01

venvic


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.

like image 33
Aqib Nawaz Avatar answered Jan 27 '26 00:01

Aqib Nawaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!