Gemini has absolutely no idea what is going on, chatgpt has no idea what is going on, i cant make this work and its driving me insane, i just have a button to write data and it just spits out 400 errors in the console.
Database security is set to public and is set up correctly and I am using anonymous authentication successfully, console shows i am signed in Signed in: DSAytCXHn2XtmYclP6hBdxaJ3eD2, but as soon as i attempt to reach out and do anything to the database I just get 400 errors.
import React, { useEffect, useState } from 'react';
import { initializeApp } from 'firebase/app';
import {
getFirestore,
initializeFirestore,
collection,
addDoc
} from 'firebase/firestore';
import {
getAuth,
signInAnonymously,
onAuthStateChanged
} from 'firebase/auth';
const firebaseConfig = {
apiKey: "",
authDomain: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: ""
};
const app = initializeApp(firebaseConfig);
// Explicitly set up Firestore with tuning for region/network issues
const db = initializeFirestore(app, {
experimentalForceLongPolling: true,
useFetchStreams: true,
});
const auth = getAuth(app);
function App() {
const [user, setUser] = useState(null);
useEffect(() => {
signInAnonymously(auth).catch((error) => {
console.error("Anonymous sign-in failed:", error);
});
onAuthStateChanged(auth, (firebaseUser) => {
if (firebaseUser) {
setUser(firebaseUser);
console.log("Signed in:", firebaseUser.uid);
}
});
}, []);
const writeTestDoc = async () => {
if (!user) {
alert("Still signing in... try again shortly.");
return;
}
try {
console.log("Attempting to write...");
const docRef = await addDoc(collection(db, 'trades'), {
test: "Hello from minimal app",
timestamp: new Date().toISOString(),
uid: user.uid
});
console.log("Success! Doc ID:", docRef.id);
alert("Success! Wrote doc: " + docRef.id);
} catch (err) {
console.error("Write failed:", err);
alert("Failed to write doc: " + err.message);
}
};
return (
<div style={{ padding: '2rem' }}>
<h1>Minimal Firestore Test</h1>
<button onClick={writeTestDoc}>Write a Test Doc</button>
</div>
);
}
export default App;
Here is the entire error message
GET https://firestore.googleapis.com/google.firestore.v1.Firestore/Write/channel?gsessionid=ATOAL2H7Jwe5BZ7MpAKV5tSpPpu8RgRzemlnciG-seg&VER=8&database=projects%2Fptd-guardian%2Fdatabases%2F(default)&RID=rpc&SID=cw4ykaMJjgqT5_EZBhAQcA&AID=0&CI=0&TYPE=xmlhttp&zx=z9kgxt5h7g5v&t=1 net::ERR_ABORTED 400 (Bad Request)
e.send @ webchannel_blob_es2018.js:52
e.ea @ webchannel_blob_es2018.js:60
ze @ webchannel_blob_es2018.js:30
on @ webchannel_blob_es2018.js:76
e.Fa @ webchannel_blob_es2018.js:75
R @ webchannel_blob_es2018.js:14
Promise.then
C @ webchannel_blob_es2018.js:14
nn @ webchannel_blob_es2018.js:74
Ge @ webchannel_blob_es2018.js:39
Le.Y @ webchannel_blob_es2018.js:33
Le.ca @ webchannel_blob_es2018.js:30
ie @ webchannel_blob_es2018.js:25
re @ webchannel_blob_es2018.js:23
Bt @ webchannel_blob_es2018.js:62
e.bb @ webchannel_blob_es2018.js:61
e.Ea @ webchannel_blob_es2018.js:61
xt @ webchannel_blob_es2018.js:57
e.Pa @ webchannel_blob_es2018.js:55
Promise.then
Ot @ webchannel_blob_es2018.js:55
e.Sa @ webchannel_blob_es2018.js:55
Promise.then
e.send @ webchannel_blob_es2018.js:52
e.ea @ webchannel_blob_es2018.js:60
ze @ webchannel_blob_es2018.js:29
Ve @ webchannel_blob_es2018.js:28
e.Ga @ webchannel_blob_es2018.js:72
R @ webchannel_blob_es2018.js:14
Promise.then
C @ webchannel_blob_es2018.js:14
Jt @ webchannel_blob_es2018.js:70
e.connect @ webchannel_blob_es2018.js:68
mn.m @ webchannel_blob_es2018.js:82
Io @ webchannel_connection.ts:260
send @ stream_bridge.ts:70
a_ @ persistent_stream.ts:322
p_ @ persistent_stream.ts:861
bu @ remote_store.ts:762
(anonymous) @ persistent_stream.ts:528
(anonymous) @ persistent_stream.ts:595
(anonymous) @ async_queue_impl.ts:136
(anonymous) @ async_queue_impl.ts:187
Promise.then
gu @ async_queue_impl.ts:185
enqueue @ async_queue_impl.ts:130
enqueueAndForget @ async_queue_impl.ts:94
(anonymous) @ persistent_stream.ts:593
(anonymous) @ persistent_stream.ts:508
wo @ stream_bridge.ts:86
(anonymous) @ webchannel_connection.ts:417
setTimeout
Bo @ webchannel_connection.ts:412
T_ @ persistent_stream.ts:801
P_ @ persistent_stream.ts:503
(anonymous) @ persistent_stream.ts:477
Promise.then
auth @ persistent_stream.ts:467
start @ persistent_stream.ts:264
start @ persistent_stream.ts:788
(anonymous) @ persistent_stream.ts:561
(anonymous) @ backoff.ts:137
(anonymous) @ async_queue.ts:196
(anonymous) @ async_queue_impl.ts:136
(anonymous) @ async_queue_impl.ts:187
Promise.then
gu @ async_queue_impl.ts:185
enqueue @ async_queue_impl.ts:130
enqueueAndForget @ async_queue_impl.ts:94
handleDelayElapsed @ async_queue.ts:193
(anonymous) @ async_queue.ts:160
setTimeout
start @ async_queue.ts:160
createAndSchedule @ async_queue.ts:151
enqueueAfterDelay @ async_queue_impl.ts:225
Go @ backoff.ts:132
i_ @ persistent_stream.ts:554
start @ persistent_stream.ts:256
start @ persistent_stream.ts:788
wu @ remote_store.ts:756
Su @ remote_store.ts:825
close @ persistent_stream.ts:419
I_ @ persistent_stream.ts:580
(anonymous) @ persistent_stream.ts:533
(anonymous) @ persistent_stream.ts:595
(anonymous) @ async_queue_impl.ts:136
(anonymous) @ async_queue_impl.ts:187
Promise.then
gu @ async_queue_impl.ts:185
enqueue @ async_queue_impl.ts:130
enqueueAndForget @ async_queue_impl.ts:94
(anonymous) @ persistent_stream.ts:593
(anonymous) @ persistent_stream.ts:532
So @ stream_bridge.ts:94
(anonymous) @ webchannel_connection.ts:332
(anonymous) @ webchannel_connection.ts:294
ie @ webchannel_blob_es2018.js:25
re @ webchannel_blob_es2018.js:23
wn.sa @ webchannel_blob_es2018.js:85
cn @ webchannel_blob_es2018.js:78
ln @ webchannel_blob_es2018.js:77
qe @ webchannel_blob_es2018.js:36
Le.Y @ webchannel_blob_es2018.js:34
Le.ca @ webchannel_blob_es2018.js:30
ie @ webchannel_blob_es2018.js:25
re @ webchannel_blob_es2018.js:23
Bt @ webchannel_blob_es2018.js:62
e.bb @ webchannel_blob_es2018.js:61
e.Ea @ webchannel_blob_es2018.js:61
xt @ webchannel_blob_es2018.js:57
e.Pa @ webchannel_blob_es2018.js:55
Promise.then
Ot @ webchannel_blob_es2018.js:55
e.Sa @ webchannel_blob_es2018.js:55
Promise.then
e.send @ webchannel_blob_es2018.js:52
e.ea @ webchannel_blob_es2018.js:60
ze @ webchannel_blob_es2018.js:30
on @ webchannel_blob_es2018.js:76
e.Fa @ webchannel_blob_es2018.js:75
R @ webchannel_blob_es2018.js:14
Promise.then
C @ webchannel_blob_es2018.js:14
nn @ webchannel_blob_es2018.js:74
Ge @ webchannel_blob_es2018.js:39
Le.Y @ webchannel_blob_es2018.js:33
Le.ca @ webchannel_blob_es2018.js:30
ie @ webchannel_blob_es2018.js:25
re @ webchannel_blob_es2018.js:23
Bt @ webchannel_blob_es2018.js:62
e.bb @ webchannel_blob_es2018.js:61
e.Ea @ webchannel_blob_es2018.js:61
xt @ webchannel_blob_es2018.js:57
e.Pa @ webchannel_blob_es2018.js:55
Promise.then
Ot @ webchannel_blob_es2018.js:55
e.Sa @ webchannel_blob_es2018.js:55
Promise.then
e.send @ webchannel_blob_es2018.js:52
e.ea @ webchannel_blob_es2018.js:60
ze @ webchannel_blob_es2018.js:29
Ve @ webchannel_blob_es2018.js:28
e.Ga @ webchannel_blob_es2018.js:72
R @ webchannel_blob_es2018.js:14
Promise.then
C @ webchannel_blob_es2018.js:14
Jt @ webchannel_blob_es2018.js:70
e.connect @ webchannel_blob_es2018.js:68
mn.m @ webchannel_blob_es2018.js:82
Io @ webchannel_connection.ts:260
send @ stream_bridge.ts:70
a_ @ persistent_stream.ts:322
p_ @ persistent_stream.ts:861
bu @ remote_store.ts:762
(anonymous) @ persistent_stream.ts:528
(anonymous) @ persistent_stream.ts:595
(anonymous) @ async_queue_impl.ts:136
(anonymous) @ async_queue_impl.ts:187
Promise.then
gu @ async_queue_impl.ts:185
enqueue @ async_queue_impl.ts:130
enqueueAndForget @ async_queue_impl.ts:94
(anonymous) @ persistent_stream.ts:593
(anonymous) @ persistent_stream.ts:508
wo @ stream_bridge.ts:86
(anonymous) @ webchannel_connection.ts:417
setTimeout
Bo @ webchannel_connection.ts:412
T_ @ persistent_stream.ts:801
P_ @ persistent_stream.ts:503
(anonymous) @ persistent_stream.ts:477
Promise.then
auth @ persistent_stream.ts:467
start @ persistent_stream.ts:264
start @ persistent_stream.ts:788
(anonymous) @ persistent_stream.ts:561
(anonymous) @ backoff.ts:137
(anonymous) @ async_queue.ts:196
(anonymous) @ async_queue_impl.ts:136
(anonymous) @ async_queue_impl.ts:187
Promise.then
gu @ async_queue_impl.ts:185
enqueue @ async_queue_impl.ts:130
enqueueAndForget @ async_queue_impl.ts:94
handleDelayElapsed @ async_queue.ts:193
(anonymous) @ async_queue.ts:160
setTimeout
start @ async_queue.ts:160
createAndSchedule @ async_queue.ts:151
enqueueAfterDelay @ async_queue_impl.ts:225
Go @ backoff.ts:132
i_ @ persistent_stream.ts:554
start @ persistent_stream.ts:256
start @ persistent_stream.ts:788
wu @ remote_store.ts:756
Su @ remote_store.ts:825
close @ persistent_stream.ts:419
I_ @ persistent_stream.ts:580
(anonymous) @ persistent_stream.ts:533
(anonymous) @ persistent_stream.ts:595
(anonymous) @ async_queue_impl.ts:136
(anonymous) @ async_queue_impl.ts:187
Promise.then
gu @ async_queue_impl.ts:185
enqueue @ async_queue_impl.ts:130
enqueueAndForget @ async_queue_impl.ts:94
(anonymous) @ persistent_stream.ts:593
(anonymous) @ persistent_stream.ts:532
So @ stream_bridge.ts:94
(anonymous) @ webchannel_connection.ts:332
(anonymous) @ webchannel_connection.ts:294
ie @ webchannel_blob_es2018.js:25
re @ webchannel_blob_es2018.js:23
wn.sa @ webchannel_blob_es2018.js:85
cn @ webchannel_blob_es2018.js:78
ln @ webchannel_blob_es2018.js:77
qe @ webchannel_blob_es2018.js:36
Le.Y @ webchannel_blob_es2018.js:34
Le.ca @ webchannel_blob_es2018.js:30
ie @ webchannel_blob_es2018.js:25
re @ webchannel_blob_es2018.js:23
Bt @ webchannel_blob_es2018.js:62
e.bb @ webchannel_blob_es2018.js:61
e.Ea @ webchannel_blob_es2018.js:61
xt @ webchannel_blob_es2018.js:57
e.Pa @ webchannel_blob_es2018.js:55
Promise.then
Ot @ webchannel_blob_es2018.js:55
e.Sa @ webchannel_blob_es2018.js:55
Promise.then
e.send @ webchannel_blob_es2018.js:52
e.ea @ webchannel_blob_es2018.js:60
ze @ webchannel_blob_es2018.js:30
on @ webchannel_blob_es2018.js:76
e.Fa @ webchannel_blob_es2018.js:75
R @ webchannel_blob_es2018.js:14
Promise.then
C @ webchannel_blob_es2018.js:14
nn @ webchannel_blob_es2018.js:74
Ge @ webchannel_blob_es2018.js:39
Le.Y @ webchannel_blob_es2018.js:33
Le.ca @ webchannel_blob_es2018.js:30
ie @ webchannel_blob_es2018.js:25
re @ webchannel_blob_es2018.js:23
Bt @ webchannel_blob_es2018.js:62
e.bb @ webchannel_blob_es2018.js:61
e.Ea @ webchannel_blob_es2018.js:61
xt @ webchannel_blob_es2018.js:57
e.Pa @ webchannel_blob_es2018.js:55
Promise.then
Ot @ webchannel_blob_es2018.js:55
e.Sa @ webchannel_blob_es2018.js:55
Promise.then
e.send @ webchannel_blob_es2018.js:52
e.ea @ webchannel_blob_es2018.js:60
ze @ webchannel_blob_es2018.js:29
Ve @ webchannel_blob_es2018.js:28
e.Ga @ webchannel_blob_es2018.js:72
R @ webchannel_blob_es2018.js:14
Promise.then
C @ webchannel_blob_es2018.js:14
Jt @ webchannel_blob_es2018.js:70
e.connect @ webchannel_blob_es2018.js:68
mn.m @ webchannel_blob_es2018.js:82
Io @ webchannel_connection.ts:260
send @ stream_bridge.ts:70
a_ @ persistent_stream.ts:322
p_ @ persistent_stream.ts:861
bu @ remote_store.ts:762
(anonymous) @ persistent_stream.ts:528
(anonymous) @ persistent_stream.ts:595
(anonymous) @ async_queue_impl.ts:136
(anonymous) @ async_queue_impl.ts:187
Promise.then
gu @ async_queue_impl.ts:185
enqueue @ async_queue_impl.ts:130
enqueueAndForget @ async_queue_impl.ts:94
(anonymous) @ persistent_stream.ts:593
(anonymous) @ persistent_stream.ts:508
wo @ stream_bridge.ts:86
(anonymous) @ webchannel_connection.ts:417
setTimeout
Bo @ webchannel_connection.ts:412
T_ @ persistent_stream.ts:801
P_ @ persistent_stream.ts:503
(anonymous) @ persistent_stream.ts:477
Promise.then
auth @ persistent_stream.ts:467
start @ persistent_stream.ts:264
start @ persistent_stream.ts:788
(anonymous) @ persistent_stream.ts:561
(anonymous) @ backoff.ts:137
(anonymous) @ async_queue.ts:196
(anonymous) @ async_queue_impl.ts:136
(anonymous) @ async_queue_impl.ts:187
Promise.then
gu @ async_queue_impl.ts:185
enqueue @ async_queue_impl.ts:130
enqueueAndForget @ async_queue_impl.ts:94
handleDelayElapsed @ async_queue.ts:193
(anonymous) @ async_queue.ts:160Understand this error
logger.ts:115 [2025-04-10T13:05:45.565Z] @firebase/firestore: Firestore (10.14.1): WebChannelConnection RPC 'Write' stream 0x51f3d779 transport errored: yn {type: 'c', target: mn, g: mn, defaultPrevented: false, status: 1}


