-
Notifications
You must be signed in to change notification settings - Fork 894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firestore: Fix spurious "Backend didn't respond within 10 seconds" errors when network just slow #8145
Conversation
🦋 Changeset detectedLatest commit: d309eaf The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1This report is too large (568,673 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.Test Logs |
@dconeybe thanks for working on this issue. I tested the PR, the query can load about 100 documents then found the below error
|
Hi @dconeybe thank you for working on the fix. |
Please try these steps:
The Now, please reproduce again and post an updated stack trace. Hopefully the stack trace from unmangled code will make more sense. |
@Valansch Unfortunately, no, I don't have any experience with dart or flutter. Would you be able to ask this question on the https://github.com/firebase/flutterfire repository? |
@dconeybe please see the error below Error log
|
@thomasdao Thanks for providing the updated stack trace. That error looks like the bug that you reported in #7652 has resurfaced. That is surprising because the bug you reported should have been fixed in v10.5.2 (and you are using v10.6.0). To rule out this issue, could you try the following:
Thanks! |
@dconeybe I updated Firebase to 10.11.0, then copy the firestore dist folder, and the query still hangs with below error:
|
@thomasdao Can you confirm that you have the Also, if you're willing, could you enable Firestore debug logging (i.e. call |
@dconeybe I've sent the debug log to your email. I've checked the branch again and it's correct:
|
@thomasdao Thank you for sending me the logs. Unfortunately, based on the logs I can confirm that this PR will NOT fix the issue you are reporting (#7860). One thing, however, that I noticed from your logs is that your app seems to using Firestore before a user is signed in, and then continue to use it after the user is signed in. This could be innocuous, or could be undesirable behavior, depending on what your app is doing. I just wanted to point it out. |
…lConnection sends
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with comments.
@@ -113,6 +113,7 @@ export interface Connection { | |||
* be called if the stream successfully established a connection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify the difference between onOpen and onConnected in the documentation? Currently the docs state that "onOpen will only be called if the stream successfully established a connection." That definition of onOpen is what I would expect for onConneted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the docs. LMK if they clarify.
The naming "onOpen" is somewhat unfortunate, as it does not actually indicate that an opened connection with the backend has been established. I think at one point this was the meaning, but the channel is now optimized to send the "handshake" with the first message to avoid an extra round-trip with the backend. So WebChannelConnection now sends onOpen as soon as it is ready to send a message so that it can send the handshake along with the first message. I added onConnected to send an event when an actual connection with the backend has been established.
@@ -148,6 +156,14 @@ describe('Watch Stream', () => { | |||
}); | |||
}); | |||
}); | |||
|
|||
it('gets connected event before first message', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the title of this a little misleading because the test doesn't appear to test for any messages. Or does it and I'm just not seeing how?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The awaitCallback()
will fail if some other callback occurs (such as a message). The test doesn't care about if the "message" callback occurs, only that "connected" occurs before it. Does that clarify?
…nOpen and onConnected
@dconeybe beside user data, I also store public settings in Firestore, so I need to setup Firestore even if the user does not sign in. |
Firestore was erroneously concluding that the connection to the backend was broken when the response to the initial listen request was large (e.g. 1000 documents) and the network speed was slow.
This bug resulted in erroneous errors that looked like this:
The fix is to propagate the first "OPEN" message from WebChannel to the online state detector so that it will consider the connection to be "alive" even though no proto messages have been received on the stream.
Googlers see b/325591749