WebChannel Transport Error, Long Polling
Operating System
Windows 11
Browser Version
Chrome/111.0.5563.65
Firebase SDK Version
9.17.1
Firebase SDK Product:
Auth, Firestore, Functions
Describe your project's tooling
React app with webpack
Describe the problem
I am often receiving a 400 error with a firestore listener in React JS, Tested on multiple browsers.
Here is the error, stack trace minimally reduced:
GET https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?gsessionid=[Truncated...] 400
k.send @ fetchxmlhttpfactory.js:270
k.da @ xhrio.js:664
ec @ channelrequest.js:570
Fd @ channelrequest.js:525
k.Ia @ webchannelbase.js:1673
xb @ run.js:140
Promise.then (async)
ub @ run.js:58
sb @ run.js:33
yc @ webchannelbase.js:1617
mc @ webchannelbase.js:2090
k.La @ channelrequest.js:619
k.ib @ channelrequest.js:596
kb @ eventtarget.js:351
C @ eventtarget.js:481
td @ xhrio.js:878
k.fb @ xhrio.js:866
k.Ha @ xhrio.js:842
hd @ fetchxmlhttpfactory.js:558
id @ fetchxmlhttpfactory.js:476
k.Ta @ fetchxmlhttpfactory.js:403
Promise.then (async)
jd @ fetchxmlhttpfactory.js:370
k.Ta @ fetchxmlhttpfactory.js:228
Promise.then (async)
jd @ fetchxmlhttpfactory.js:370
k.Wa @ fetchxmlhttpfactory.js:355
Promise.then (async)
k.send @ fetchxmlhttpfactory.js:270
k.da @ xhrio.js:664
ec @ channelrequest.js:570
Fd @ channelrequest.js:525
k.Ia @ webchannelbase.js:1673
xb @ run.js:140
Promise.then (async)
ub @ run.js:58
sb @ run.js:33
yc @ webchannelbase.js:1617
mc @ webchannelbase.js:2090
k.La @ channelrequest.js:619
k.ib @ channelrequest.js:596
kb @ eventtarget.js:351
C @ eventtarget.js:481
td @ xhrio.js:878
k.fb @ xhrio.js:866
k.Ha @ xhrio.js:842
hd @ fetchxmlhttpfactory.js:558
id @ fetchxmlhttpfactory.js:476
k.Ta @ fetchxmlhttpfactory.js:403
Promise.then (async)
jd @ fetchxmlhttpfactory.js:370
k.Ta @ fetchxmlhttpfactory.js:228
Promise.then (async)
jd @ fetchxmlhttpfactory.js:370
k.Ta @ fetchxmlhttpfactory.js:228
Promise.then (async)
jd @ fetchxmlhttpfactory.js:370
k.Ta @ fetchxmlhttpfactory.js:228
Promise.then (async)
jd @ fetchxmlhttpfactory.js:370
k.Ta @ fetchxmlhttpfactory.js:228
Promise.then (async)
jd @ fetchxmlhttpfactory.js:370
k.Wa @ fetchxmlhttpfactory.js:355
Promise.then (async)
k.send @ fetchxmlhttpfactory.js:270
k.da @ xhrio.js:664
ec @ channelrequest.js:570
Fd @ channelrequest.js:525
k.Ia @ webchannelbase.js:1673
xb @ run.js:140
Promise.then (async)
ub @ run.js:58
sb @ run.js:33
yc @ webchannelbase.js:1617
kc @ webchannelbase.js:2331
lc @ channelrequest.js:941
k.La @ channelrequest.js:619
k.ib @ channelrequest.js:596
kb @ eventtarget.js:351
C @ eventtarget.js:481
td @ xhrio.js:878
k.fb @ xhrio.js:866
k.Ha @ xhrio.js:842
hd @ fetchxmlhttpfactory.js:558
k.Ta @ fetchxmlhttpfactory.js:403
Promise.then (async)
jd @ fetchxmlhttpfactory.js:370
k.Wa @ fetchxmlhttpfactory.js:355
Promise.then (async)
k.send @ fetchxmlhttpfactory.js:270
k.da @ xhrio.js:664
ec @ channelrequest.js:570
cc @ channelrequest.js:504
k.Ja @ webchannelbase.js:1331
xb @ run.js:140
Promise.then (async)
ub @ run.js:58
sb @ run.js:33
zc @ webchannelbase.js:1258
X.m @ webchannelbase.js:778
Hr @ index.esm2017.js:13053
send @ index.esm2017.js:12877
Bo @ index.esm2017.js:13392
zo @ index.esm2017.js:13554
xu @ index.esm2017.js:13905
(anonymous) @ index.esm2017.js:13940
$u @ index.esm2017.js:13939
(anonymous) @ index.esm2017.js:13472
(anonymous) @ index.esm2017.js:13500
(anonymous) @ index.esm2017.js:17414
(anonymous) @ index.esm2017.js:17447
Promise.then (async)
Hc @ index.esm2017.js:17447
enqueue @ index.esm2017.js:17414
enqueueAndForget @ index.esm2017.js:17392
(anonymous) @ index.esm2017.js:13500
(anonymous) @ index.esm2017.js:13472
so @ index.esm2017.js:12880
(anonymous) @ index.esm2017.js:13120
setTimeout (async)
wo @ index.esm2017.js:13115
jo @ index.esm2017.js:13518
Go @ index.esm2017.js:13471
(anonymous) @ index.esm2017.js:13461
Promise.then (async)
auth @ index.esm2017.js:13452
start @ index.esm2017.js:13357
(anonymous) @ index.esm2017.js:13482
(anonymous) @ index.esm2017.js:13258
(anonymous) @ index.esm2017.js:14306
(anonymous) @ index.esm2017.js:17414
(anonymous) @ index.esm2017.js:17447
Promise.then (async)
Hc @ index.esm2017.js:17447
enqueue @ index.esm2017.js:17414
enqueueAndForget @ index.esm2017.js:17392
handleDelayElapsed @ index.esm2017.js:14306
(anonymous) @ index.esm2017.js:14288
setTimeout (async)
start @ index.esm2017.js:14288
createAndSchedule @ index.esm2017.js:14282
enqueueAfterDelay @ index.esm2017.js:17487
Ro @ index.esm2017.js:13258
Oo @ index.esm2017.js:13481
start @ index.esm2017.js:13357
ku @ index.esm2017.js:13920
Bu @ index.esm2017.js:13947
close @ index.esm2017.js:13442
Qo @ index.esm2017.js:13491
(anonymous) @ index.esm2017.js:13475
(anonymous) @ index.esm2017.js:13500
(anonymous) @ index.esm2017.js:17414
(anonymous) @ index.esm2017.js:17447
Promise.then (async)
Hc @ index.esm2017.js:17447
enqueue @ index.esm2017.js:17414
enqueueAndForget @ index.esm2017.js:17392
(anonymous) @ index.esm2017.js:13500
(anonymous) @ index.esm2017.js:13475
io @ index.esm2017.js:12883
(anonymous) @ index.esm2017.js:13079
(anonymous) @ index.esm2017.js:13062
kb @ eventtarget.js:351
C @ eventtarget.js:481
Y.va @ webchannelbasetransport.js:428
R @ webchannelbase.js:2375
mc @ webchannelbase.js:2147
Q @ webchannelbase.js:522
k.La @ channelrequest.js:698
k.ib @ channelrequest.js:596
kb @ eventtarget.js:351
C @ eventtarget.js:481
td @ xhrio.js:878
k.fb @ xhrio.js:866
k.Ha @ xhrio.js:842
hd @ fetchxmlhttpfactory.js:558
k.Ta @ fetchxmlhttpfactory.js:403
Promise.then (async)
jd @ fetchxmlhttpfactory.js:370
k.Wa @ fetchxmlhttpfactory.js:355
Promise.then (async)
k.send @ fetchxmlhttpfactory.js:270
k.da @ xhrio.js:664
ec @ channelrequest.js:570
Fd @ channelrequest.js:525
k.Ia @ webchannelbase.js:1673
xb @ run.js:140
Promise.then (async)
ub @ run.js:58
sb @ run.js:33
yc @ webchannelbase.js:1617
mc @ webchannelbase.js:2090
k.La @ channelrequest.js:619
k.ib @ channelrequest.js:596
kb @ eventtarget.js:351
C @ eventtarget.js:481
td @ xhrio.js:878
k.fb @ xhrio.js:866
k.Ha @ xhrio.js:842
hd @ fetchxmlhttpfactory.js:558
id @ fetchxmlhttpfactory.js:476
k.Ta @ fetchxmlhttpfactory.js:403
Promise.then (async)
jd @ fetchxmlhttpfactory.js:370
k.Ta @ fetchxmlhttpfactory.js:228
Promise.then (async)
jd @ fetchxmlhttpfactory.js:370
k.Wa @ fetchxmlhttpfactory.js:355
Promise.then (async)
k.send @ fetchxmlhttpfactory.js:270
k.da @ xhrio.js:664
ec @ channelrequest.js:570
Fd @ channelrequest.js:525
k.Ia @ webchannelbase.js:1673
xb @ run.js:140
Promise.then (async)
ub @ run.js:58
sb @ run.js:33
yc @ webchannelbase.js:1617
mc @ webchannelbase.js:2090
k.La @ channelrequest.js:619
k.ib @ channelrequest.js:596
kb @ eventtarget.js:351
C @ eventtarget.js:481
td @ xhrio.js:878
k.fb @ xhrio.js:866
k.Ha @ xhrio.js:842
hd @ fetchxmlhttpfactory.js:558
id @ fetchxmlhttpfactory.js:476
k.Ta @ fetchxmlhttpfactory.js:403
Promise.then (async)
jd @ fetchxmlhttpfactory.js:370
k.Ta @ fetchxmlhttpfactory.js:228
Promise.then (async)
etc...
React Devtools Warning
@firebase/firestore: Firestore (9.17.1): Connection WebChannel transport errored:
Jd {type: 'c', target: X, g: X, defaultPrevented: false, status: 1}
defaultPrevented
:
false
g
:
X {s: false, o: undefined, i: Ua, P: X, I: null, …}
status
:
1
target
:
X {s: false, o: undefined, i: Ua, P: X, I: null, …}
type
:
"c"
[[Prototype]]
:
Wb
Using setLogLevel('debug') I have found the following error logs:
[2023-06-04T21:54:23.588Z] @firebase/firestore: Firestore (9.22.1): PersistentStream close with error: FirebaseError: [code=unavailable]: The operation could not be completed
logger.ts:115 [2023-06-04T21:54:23.591Z] @firebase/firestore: Firestore (9.22.1): WebChannelConnection Creating RPC 'Listen' stream 0x86195108: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel {"httpSessionIdParam":"gsessionid","initMessageHeaders":{"X-Goog-Api-Client":"gl-js/ fire/9.22.1","Content-Type":"text/plain","X-Firebase-GMPID":"1:845193017408:web:d13f2eab4cf84fbe2e47a5","Authorization":"Bearer |OMITTED|"},"messageUrlParams":{"database":"projects/|OMITTED|/databases/(default)"},"sendRawJson":true,"supportsCrossDomainXhr":true,"internalChannelParams":{"forwardChannelRequestTimeoutMs":600000},"forceLongPolling":false,"detectBufferingProxy":true,"xmlHttpFactory":{"l":null,"j":false},"encodeInitMessageHeaders":true}
This looks like a timeout error, but I think I am correctly unsubscribing to the listener. This may be an issue with the useCallback() hook nature.
Steps and code to reproduce issue
Here is how I am initializing Firestore:
import { initializeApp } from "firebase/app";
import { initializeFirestore } from "firebase/firestore";
const fK = process.env.REACT_APP_FK;
const fDom = process.env.REACT_APP_FDOM;
const pId = process.env.REACT_APP_FPID;
const fSB = process.env.REACT_APP_FSB;
const fMSID = process.env.REACT_APP_FMSID;
const fId = process.env.REACT_APP_FID;
const fMID = process.env.REACT_APP_FMID;
const firebaseConfig = {
apiKey: fK,
authDomain: fDom,
projectId: pId,
storageBucket: fSB,
messagingSenderId: fMSID,
appId: fId,
measurementId: fMID
};
export const app = initializeApp(firebaseConfig);
export const db = initializeFirestore(app, {
experimentalAutoDetectLongPolling: true,
});
I have also tried experimentalForceLongPolling, and disabling useFetchStreams. using getFirestore() to initialize firestore does not work either, I still get the same error.
MRE
const fetchUserData = useCallback(() => {
if (!navigator.onLine) {
navigate("/");
return;
}
if (auth.currentUser) {
const docRef = doc(db, "users", auth.currentUser.uid);
const unsubscribe = onSnapshot(
docRef,
(docSnap) => {
if (docSnap.exists()) {
const userData = docSnap.data();
// Handle userData
}
},
(error) => {
handleLogout();
console.error("Error fetching user data:", error);
}
);
// Cleanup function to detach listener
return () => {
unsubscribe();
};
} else {
navigate("/");
}
}, [navigate, handleLogout]);
useEffect(() => {
try {
fetchUserData();
} catch (error) {
setInfo("User data not found");
console.error(error);
navigate("/");
}
}, [fetchUserData, navigate]);
I have a feeling that it may have to do with my useEffect() and useCallback() hooks, but I am uncertain. The user data is working fine, changes in the user document are seen from the app, but this error always occurs multiple times.
Can you try to visit https://debug-my.firebaseapp.com/ and tell us what you see?
@wu-hui Here is an extract from the output from https://debug-my.firebaseapp.com/
[ 22.156s] [diagnostic] >>> [TEST 7/9: Firestore listen test with default options] Received message: [{"targetChange":{"targetChangeType":"ADD","targetIds":[2]}}]
[ 22.157s] [diagnostic] >>> [TEST 7/9: Firestore listen test with default options] Received message: [{"documentChange":{"document":{"name":"projects/debug-my/databases/(default)/documents/debug/000","fields":{"desc":{"stringValue":"Diagnostic Document 0"}},"createTime":"2019-12-28T19:50:18.256728Z","updateTime":"2019-12-28T19:50:18.256728Z"},"targetIds":[2]}}]
[ 22.159s] [diagnostic] >>> [TEST 7/9: Firestore listen test with default options] Received message: [{"documentChange":{"document":{"name":"projects/debug-my/databases/(default)/documents/debug/001","fields":{"desc":{"stringValue":"Diagnostic Document 1"}},"createTime":"2019-12-28T19:50:31.803733Z","updateTime":"2019-12-28T19:50:31.803733Z"},"targetIds":[2]}}]
[ 22.160s] [diagnostic] >>> [TEST 7/9: Firestore listen test with default options] Received message: [{"documentChange":{"document":{"name":"projects/debug-my/databases/(default)/documents/debug/002","fields":{"desc":{"stringValue":"Diagnostic Document 2"}},"createTime":"2019-12-28T19:50:37.682905Z","updateTime":"2019-12-28T19:50:43.797778Z"},"targetIds":[2]}}]
[ 22.161s] [diagnostic] >>> [TEST 7/9: Firestore listen test with default options] Received message: [{"documentChange":{"document":{"name":"projects/debug-my/databases/(default)/documents/debug/003","fields":{"desc":{"stringValue":"Diagnostic Document 3"}},"createTime":"2019-12-28T19:50:52.602052Z","updateTime":"2019-12-28T19:50:52.602052Z"},"targetIds":[2]}}]
[ 22.162s] [diagnostic]
********************************************************
[TEST 7/9: Firestore listen test with default options] completed successfully.
********************************************************
[ 22.163s] [goog.labs.net.webChannel.WebChannelDebug] disconnect()
[ 22.165s] [goog.labs.net.webChannel.WebChannelBaseTransport] WebChannel closed on https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel
[ 22.166s] [diagnostic] >>> [TEST 7/9: Firestore listen test with default options] channel closed
[ 23.893s] [diagnostic]
********************************************************
[TEST 8/9: Firestore listen test with detectBufferingProxy] STARTING at 2023-06-13T16:20:04.525Z]
********************************************************
[ 23.895s] [diagnostic] >>> [TEST 8/9: Firestore listen test with detectBufferingProxy] createWebChannel("https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel", {"backgroundChannelTest":true,"httpSessionIdParam":"gsessionid","initMessageHeaders":{},"sendRawJson":true,"supportsCrossDomainXhr":true,"internalChannelParams":{"forwardChannelRequestTimeoutMs":600000},"httpHeadersOverwriteParam":"$httpHeaders","disableRedact":true,"detectBufferingProxy":true,"messageUrlParams":{"database":"projects/debug-my/databases/(default)"}})
[ 23.897s] [diagnostic] >>> [TEST 8/9: Firestore listen test with detectBufferingProxy] open()
[ 23.899s] [goog.labs.net.webChannel.WebChannelDebug] connect()
[ 23.901s] [goog.labs.net.webChannel.WebChannelDebug] Origin Trials enabled.
[ 23.902s] [diagnostic] RequestStat event: 0
[ 23.904s] [diagnostic] RequestStat event: 0
[ 23.906s] [diagnostic] RequestStat event: 0
[ 23.907s] [diagnostic] RequestStat event: 0
[ 23.909s] [diagnostic] RequestStat event: 0
[ 23.911s] [diagnostic] RequestStat event: 0
[ 23.912s] [diagnostic] RequestStat event: 0
[ 23.913s] [goog.labs.net.webChannel.WebChannelDebug] connectChannel_()
[ 23.915s] [goog.labs.net.webChannel.WebChannelDebug] GetForwardChannelUri: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=projects%2Fdebug-my%2Fdatabases%2F(default)&VER=8
[ 23.917s] [diagnostic] >>> [TEST 8/9: Firestore listen test with detectBufferingProxy] channel.send({"database":"projects/debug-my/databases/(default)","addTarget":{"query":{"structuredQuery":{"from":[{"collectionId":"debug"}],"orderBy":[{"field":{"fieldPath":"__name__"},"direction":"ASCENDING"}]},"parent":"projects/debug-my/databases/(default)/documents"},"targetId":2}})
[ 23.919s] [goog.labs.net.webChannel.WebChannelDebug] Origin Trials invoked: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel
[ 23.921s] [goog.labs.net.webChannel.WebChannelDebug] startForwardChannel_
[ 23.922s] [goog.labs.net.webChannel.WebChannelDebug] open_()
[ 23.925s] [goog.labs.net.webChannel.WebChannelDebug] XMLHTTP REQ (76356) [attempt 1]: POST
https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=(OMITTED)
[ 24.045s] [goog.labs.net.webChannel.WebChannelDebug] XMLHTTP RESP (76356) [ attempt 1]: POST
https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=(OMITTED)
3 200
[ 24.046s] [goog.labs.net.webChannel.WebChannelDebug] XMLHTTP TEXT (76356): [[0,["c","(OMITTED)","",8,12,30000]]]
[ 24.047s] [goog.labs.net.webChannel.WebChannelDebug] VER=8
[ 24.049s] [goog.labs.net.webChannel.WebChannelDebug] SVER=12
[ 24.050s] [goog.labs.net.webChannel.WebChannelDebug] backChannelRequestTimeoutMs_=45000
[ 24.051s] [goog.labs.net.webChannel.WebChannelBaseTransport] WebChannel opened on https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel
[ 24.052s] [diagnostic] >>> [TEST 8/9: Firestore listen test with detectBufferingProxy] channel opened: 157ms (1686673204684)
concurrent request limit : 10
isSpdyEnabled : true
[ 24.054s] [goog.labs.net.webChannel.WebChannelDebug] Handshake RTT: 130ms
[ 24.055s] [goog.labs.net.webChannel.WebChannelDebug] GetBackChannelUri: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=(OMITTED)
[ 24.056s] [goog.labs.net.webChannel.WebChannelDebug] Creating new HttpRequest
[ 24.059s] [goog.labs.net.webChannel.WebChannelDebug] XMLHTTP REQ (rpc) [attempt 1]: GET
https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=(OMITTED)
null
[ 24.060s] [goog.labs.net.webChannel.WebChannelDebug] New Request created
[ 24.061s] [goog.labs.net.webChannel.WebChannelDebug] BP detection timer enabled: 260
[ 24.063s] [goog.labs.net.webChannel.WebChannelDebug] XMLHTTP RESP (76356) [ attempt 1]: POST
https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=(OMMITED)
4 200
[ 24.065s] [goog.labs.net.webChannel.WebChannelDebug] Request complete
[ 24.066s] [goog.labs.net.webChannel.WebChannelDebug] startForwardChannel_
[ 24.067s] [goog.labs.net.webChannel.WebChannelDebug] startForwardChannel_ returned: nothing to send
[ 24.172s] [goog.labs.net.webChannel.WebChannelDebug] XMLHTTP RESP (rpc) [ attempt 1]: GET
https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=(OMITTED)
3 200
[ 24.174s] [goog.labs.net.webChannel.WebChannelDebug] XMLHTTP TEXT (rpc): [[1,[{
"targetChange": {
"targetChangeType": "ADD",
"targetIds": [
2
]
}
}
]],[2,[{
"documentChange": {
"document": {
"name": "projects/debug-my/databases/(default)/documents/debug/000",
"fields": {
"desc": {
"stringValue": "Diagnostic Document 0"
}
},
"createTime": "2019-12-28T19:50:18.256728Z",
"updateTime": "2019-12-28T19:50:18.256728Z"
},
"targetIds": [
2
]
}
}
]],[3,[{
"documentChange": {
"document": {
"name": "projects/debug-my/databases/(default)/documents/debug/001",
"fields": {
"desc": {
"stringValue": "Diagnostic Document 1"
}
},
"createTime": "2019-12-28T19:50:31.803733Z",
"updateTime": "2019-12-28T19:50:31.803733Z"
},
"targetIds": [
2
]
}
}
]],[4,[{
"documentChange": {
"document": {
"name": "projects/debug-my/databases/(default)/documents/debug/002",
"fields": {
"desc": {
"stringValue": "Diagnostic Document 2"
}
},
"createTime": "2019-12-28T19:50:37.682905Z",
"updateTime": "2019-12-28T19:50:43.797778Z"
},
"targetIds": [
2
]
}
}
]],[5,[{
"documentChange": {
"document": {
"name": "projects/debug-my/databases/(default)/documents/debug/003",
"fields": {
"desc": {
"stringValue": "Diagnostic Document 3"
}
},
"createTime": "2019-12-28T19:50:52.602052Z",
"updateTime": "2019-12-28T19:50:52.602052Z"
},
"targetIds": [
2
]
}
}
]],[6,[{
"documentChange": {
"document": {
"name": "projects/debug-my/databases/(default)/documents/debug/004",
"fields": {
"desc": {
"stringValue": "Diagnostic Document 4"
}
},
"createTime": "2019-12-28T19:50:59.545646Z",
"updateTime": "2019-12-28T19:50:59.545646Z"
},
"targetIds": [
2
]
}
}
]],[7,[{
"targetChange": {
"targetChangeType": "CURRENT",
"targetIds": [
2
],
"resumeToken": "CgkItfmpqtPA/wI=",
"readTime": "2023-06-13T16:20:05.918901Z"
}
}
]],[8,[{
"targetChange": {
"resumeToken": "CgkItfmpqtPA/wI=",
"readTime": "2023-06-13T16:20:05.918901Z"
}
}
]]]
[ 24.176s] [diagnostic] >>> [TEST 8/9: Firestore listen test with detectBufferingProxy] Received message: [{"targetChange":{"targetChangeType":"ADD","targetIds":[2]}}]
[ 24.178s] [diagnostic] >>> [TEST 8/9: Firestore listen test with detectBufferingProxy] Received message: [{"documentChange":{"document":{"name":"projects/debug-my/databases/(default)/documents/debug/000","fields":{"desc":{"stringValue":"Diagnostic Document 0"}},"createTime":"2019-12-28T19:50:18.256728Z","updateTime":"2019-12-28T19:50:18.256728Z"},"targetIds":[2]}}]
[ 24.179s] [diagnostic] >>> [TEST 8/9: Firestore listen test with detectBufferingProxy] Received message: [{"documentChange":{"document":{"name":"projects/debug-my/databases/(default)/documents/debug/001","fields":{"desc":{"stringValue":"Diagnostic Document 1"}},"createTime":"2019-12-28T19:50:31.803733Z","updateTime":"2019-12-28T19:50:31.803733Z"},"targetIds":[2]}}]
[ 24.180s] [diagnostic] >>> [TEST 8/9: Firestore listen test with detectBufferingProxy] Received message: [{"documentChange":{"document":{"name":"projects/debug-my/databases/(default)/documents/debug/002","fields":{"desc":{"stringValue":"Diagnostic Document 2"}},"createTime":"2019-12-28T19:50:37.682905Z","updateTime":"2019-12-28T19:50:43.797778Z"},"targetIds":[2]}}]
[ 24.181s] [diagnostic] >>> [TEST 8/9: Firestore listen test with detectBufferingProxy] Received message: [{"documentChange":{"document":{"name":"projects/debug-my/databases/(default)/documents/debug/003","fields":{"desc":{"stringValue":"Diagnostic Document 3"}},"createTime":"2019-12-28T19:50:52.602052Z","updateTime":"2019-12-28T19:50:52.602052Z"},"targetIds":[2]}}]
[ 24.182s] [diagnostic]
********************************************************
[TEST 8/9: Firestore listen test with detectBufferingProxy] completed successfully.
********************************************************
[ 24.184s] [goog.labs.net.webChannel.WebChannelDebug] disconnect()
[ 24.185s] [goog.labs.net.webChannel.WebChannelDebug] Cancel the BP detection timer.
[ 24.187s] [goog.labs.net.webChannel.WebChannelBaseTransport] WebChannel closed on https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel
[ 24.188s] [diagnostic] >>> [TEST 8/9: Firestore listen test with detectBufferingProxy] channel closed
[ 25.893s] [diagnostic]
********************************************************
[TEST 9/9: Firestore listen test with forceLongPolling] STARTING at 2023-06-13T16:20:06.525Z]
********************************************************
[ 25.894s] [diagnostic] >>> [TEST 9/9: Firestore listen test with forceLongPolling] createWebChannel("https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel", {"backgroundChannelTest":true,"httpSessionIdParam":"gsessionid","initMessageHeaders":{},"sendRawJson":true,"supportsCrossDomainXhr":true,"internalChannelParams":{"forwardChannelRequestTimeoutMs":600000},"httpHeadersOverwriteParam":"$httpHeaders","disableRedact":true,"forceLongPolling":true,"messageUrlParams":{"database":"projects/debug-my/databases/(default)"}})
[ 25.896s] [diagnostic] >>> [TEST 9/9: Firestore listen test with forceLongPolling] open()
[ 25.897s] [goog.labs.net.webChannel.WebChannelDebug] connect()
[ 25.898s] [goog.labs.net.webChannel.WebChannelDebug] Origin Trials enabled.
[ 25.899s] [diagnostic] RequestStat event: 0
[ 25.900s] [diagnostic] RequestStat event: 0
[ 25.901s] [diagnostic] RequestStat event: 0
[ 25.902s] [diagnostic] RequestStat event: 0
[ 25.903s] [diagnostic] RequestStat event: 0
[ 25.904s] [diagnostic] RequestStat event: 0
[ 25.905s] [diagnostic] RequestStat event: 0
[ 25.906s] [diagnostic] RequestStat event: 0
[ 25.907s] [goog.labs.net.webChannel.WebChannelDebug] connectChannel_()
[ 25.908s] [goog.labs.net.webChannel.WebChannelDebug] GetForwardChannelUri: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=(OMITTED)
[ 25.910s] [diagnostic] >>> [TEST 9/9: Firestore listen test with forceLongPolling] channel.send({"database":"projects/debug-my/databases/(default)","addTarget":{"query":{"structuredQuery":{"from":[{"collectionId":"debug"}],"orderBy":[{"field":{"fieldPath":"__name__"},"direction":"ASCENDING"}]},"parent":"projects/debug-my/databases/(default)/documents"},"targetId":2}})
[ 25.912s] [goog.labs.net.webChannel.WebChannelDebug] Origin Trials invoked: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel
[ 25.913s] [goog.labs.net.webChannel.WebChannelDebug] startForwardChannel_
[ 25.914s] [goog.labs.net.webChannel.WebChannelDebug] open_()
[ 25.916s] [goog.labs.net.webChannel.WebChannelDebug] XMLHTTP REQ (67798) [attempt 1]: POST
https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=(OMITTED)
[ 26.036s] [goog.labs.net.webChannel.WebChannelDebug] XMLHTTP RESP (67798) [ attempt 1]: POST
https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=(OMITTED)
3 200
[ 26.037s] [goog.labs.net.webChannel.WebChannelDebug] XMLHTTP TEXT (67798): [[0,["c","(OMITTED)","",8,12,30000]]]
[ 26.038s] [goog.labs.net.webChannel.WebChannelDebug] VER=8
[ 26.039s] [goog.labs.net.webChannel.WebChannelDebug] SVER=12
[ 26.040s] [goog.labs.net.webChannel.WebChannelDebug] backChannelRequestTimeoutMs_=45000
[ 26.041s] [goog.labs.net.webChannel.WebChannelBaseTransport] WebChannel opened on https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel
[ 26.042s] [diagnostic] >>> [TEST 9/9: Firestore listen test with forceLongPolling] channel opened: 148ms (1686673206674)
concurrent request limit : 10
isSpdyEnabled : true
[ 26.043s] [goog.labs.net.webChannel.WebChannelDebug] GetBackChannelUri: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=(OMITTED)
[ 26.044s] [goog.labs.net.webChannel.WebChannelDebug] Creating new HttpRequest
[ 26.045s] [goog.labs.net.webChannel.WebChannelDebug] XMLHTTP REQ (rpc) [attempt 1]: GET
https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=(OMITTED)
null
[ 26.047s] [goog.labs.net.webChannel.WebChannelDebug] New Request created
[ 26.048s] [goog.labs.net.webChannel.WebChannelDebug] XMLHTTP RESP (67798) [ attempt 1]: POST
https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=(OMITTED)
4 200
[ 26.050s] [goog.labs.net.webChannel.WebChannelDebug] Request complete
[ 26.051s] [goog.labs.net.webChannel.WebChannelDebug] startForwardChannel_
[ 26.052s] [goog.labs.net.webChannel.WebChannelDebug] startForwardChannel_ returned: nothing to send
[ 26.158s] [goog.labs.net.webChannel.WebChannelDebug] XMLHTTP RESP (rpc) [ attempt 1]: GET
https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=(OMITTED)
3 200
[ 26.159s] [goog.labs.net.webChannel.WebChannelDebug] XMLHTTP TEXT (rpc): [[1,[{
"targetChange": {
"targetChangeType": "ADD",
"targetIds": [
2
]
}
}
]],[2,[{
"documentChange": {
"document": {
"name": "projects/debug-my/databases/(default)/documents/debug/000",
"fields": {
"desc": {
"stringValue": "Diagnostic Document 0"
}
},
"createTime": "2019-12-28T19:50:18.256728Z",
"updateTime": "2019-12-28T19:50:18.256728Z"
},
"targetIds": [
2
]
}
}
]],[3,[{
"documentChange": {
"document": {
"name": "projects/debug-my/databases/(default)/documents/debug/001",
"fields": {
"desc": {
"stringValue": "Diagnostic Document 1"
}
},
"createTime": "2019-12-28T19:50:31.803733Z",
"updateTime": "2019-12-28T19:50:31.803733Z"
},
"targetIds": [
2
]
}
}
]],[4,[{
"documentChange": {
"document": {
"name": "projects/debug-my/databases/(default)/documents/debug/002",
"fields": {
"desc": {
"stringValue": "Diagnostic Document 2"
}
},
"createTime": "2019-12-28T19:50:37.682905Z",
"updateTime": "2019-12-28T19:50:43.797778Z"
},
"targetIds": [
2
]
}
}
]],[5,[{
"documentChange": {
"document": {
"name": "projects/debug-my/databases/(default)/documents/debug/003",
"fields": {
"desc": {
"stringValue": "Diagnostic Document 3"
}
},
"createTime": "2019-12-28T19:50:52.602052Z",
"updateTime": "2019-12-28T19:50:52.602052Z"
},
"targetIds": [
2
]
}
}
]],[6,[{
"documentChange": {
"document": {
"name": "projects/debug-my/databases/(default)/documents/debug/004",
"fields": {
"desc": {
"stringValue": "Diagnostic Document 4"
}
},
"createTime": "2019-12-28T19:50:59.545646Z",
"updateTime": "2019-12-28T19:50:59.545646Z"
},
"targetIds": [
2
]
}
}
]],[7,[{
"targetChange": {
"targetChangeType": "CURRENT",
"targetIds": [
2
],
"resumeToken": (OMITTED),
"readTime": "2023-06-13T16:20:07.908708Z"
}
}
]],[8,[{
"targetChange": {
"resumeToken": (OMITTED),
"readTime": "2023-06-13T16:20:07.908708Z"
}
}
]]]
[ 26.162s] [diagnostic] >>> [TEST 9/9: Firestore listen test with forceLongPolling] Received message: [{"targetChange":{"targetChangeType":"ADD","targetIds":[2]}}]
[ 26.164s] [diagnostic] >>> [TEST 9/9: Firestore listen test with forceLongPolling] Received message: [{"documentChange":{"document":{"name":"projects/debug-my/databases/(default)/documents/debug/000","fields":{"desc":{"stringValue":"Diagnostic Document 0"}},"createTime":"2019-12-28T19:50:18.256728Z","updateTime":"2019-12-28T19:50:18.256728Z"},"targetIds":[2]}}]
[ 26.165s] [diagnostic] >>> [TEST 9/9: Firestore listen test with forceLongPolling] Received message: [{"documentChange":{"document":{"name":"projects/debug-my/databases/(default)/documents/debug/001","fields":{"desc":{"stringValue":"Diagnostic Document 1"}},"createTime":"2019-12-28T19:50:31.803733Z","updateTime":"2019-12-28T19:50:31.803733Z"},"targetIds":[2]}}]
[ 26.166s] [diagnostic] >>> [TEST 9/9: Firestore listen test with forceLongPolling] Received message: [{"documentChange":{"document":{"name":"projects/debug-my/databases/(default)/documents/debug/002","fields":{"desc":{"stringValue":"Diagnostic Document 2"}},"createTime":"2019-12-28T19:50:37.682905Z","updateTime":"2019-12-28T19:50:43.797778Z"},"targetIds":[2]}}]
[ 26.167s] [diagnostic] >>> [TEST 9/9: Firestore listen test with forceLongPolling] Received message: [{"documentChange":{"document":{"name":"projects/debug-my/databases/(default)/documents/debug/003","fields":{"desc":{"stringValue":"Diagnostic Document 3"}},"createTime":"2019-12-28T19:50:52.602052Z","updateTime":"2019-12-28T19:50:52.602052Z"},"targetIds":[2]}}]
[ 26.168s] [diagnostic]
********************************************************
[TEST 9/9: Firestore listen test with forceLongPolling] completed successfully.
********************************************************
[ 26.169s] [goog.labs.net.webChannel.WebChannelDebug] disconnect()
[ 26.171s] [goog.labs.net.webChannel.WebChannelBaseTransport] WebChannel closed on https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel
[ 26.173s] [diagnostic] >>> [TEST 9/9: Firestore listen test with forceLongPolling] channel closed
[ 27.890s] [diagnostic]
********************************************************
All tests done.
1: webchannel.googleapis.com with default options: SUCCEEDED (1658ms)
2: webchannel.googleapis.com with detectBufferingProxy: SUCCEEDED (1461ms)
3: webchannel.googleapis.com with forceLongPolling: SUCCEEDED (1955ms)
4: webchannel.sandbox.google.com with default options: SUCCEEDED (1623ms)
5: webchannel.sandbox.google.com with detectBufferingProxy: SUCCEEDED (1593ms)
6: webchannel.sandbox.google.com with forceLongPolling: SUCCEEDED (2277ms)
7: Firestore listen test with default options: SUCCEEDED (264ms)
8: Firestore listen test with detectBufferingProxy: SUCCEEDED (289ms)
9: Firestore listen test with forceLongPolling: SUCCEEDED (275ms)
********************************************************
[ 46.700s] [goog.labs.net.webChannel.WebChannelDebug] TIMEOUT: null
[ 49.632s] [goog.labs.net.webChannel.WebChannelDebug] TIMEOUT: null
[ 53.098s] [goog.labs.net.webChannel.WebChannelDebug] TIMEOUT: null
[ 56.526s] [goog.labs.net.webChannel.WebChannelDebug] TIMEOUT: null
[ 60.498s] [goog.labs.net.webChannel.WebChannelDebug] TIMEOUT: null
[ 65.181s] [goog.labs.net.webChannel.WebChannelDebug] TIMEOUT: null
[ 67.167s] [goog.labs.net.webChannel.WebChannelDebug] TIMEOUT: null
... continues
Update: I have upgraded to firebase sdk 19.23.0, the issue persists.
Its been months, no solution found yet... Currently using firebase sdk 10.4.0
Hi @nxfi777, can you try to set FirestoreSettings.experimentalAutoDetectLongPolling to false and see if you can reproduce this issue?
any update guys on this issue?
same problem
@armanism24, @userbox020, I'm reading through the original issue and it appears to be a transient network issue that the SDK is able to recover from, using built-in retry mechanisms. Or, at least that's my understanding based on the following:
The user data is working fine, changes in the user document are seen from the app, but this error always occurs multiple times.
Is that also true for you? Or are you seeing a different behavior such that the SDK is not receiving document updates?
I know it's an old post, but regarding @nxfi777's concern:
I have a feeling that it may have to do with my useEffect() and useCallback() hooks, but I am uncertain
The react code shown does not return a cleanup function from the useEffect setup function, so it looks like the snapshot listener is never unsubscribed. It's unclear if this would lead to the error you're experiencing, but it could lead to errors/warnings in the log.
A react community may be able to give you better guidance, but I would try returning the unsubscribe function from your setup function:
useEffect(() => {
const unsubscribe = onSnapshot(query, onNext);
return unsubscribe;
}, []);
I solve the issue on my side, nothing related to way you saying guys but thanks to try to help
Hello @userbox020 , can you tell us what was the way you found to solve it?
Hello @userbox020 , can you tell us what was the way you found to solve it?
No bro, it was4 months ago, cant even remember what i had for breakfast last week
Same problem.