Firestore: Add ability to configure long polling timeout by dconeybe · Pull Request #7176 · firebase/firebase-js-sdk (original) (raw)
Add a new setting for Firestore: experimentalLongPollingOptions.timeoutSeconds. This new option can be used to configure the SDK’s underlying network transport (WebChannel) when long-polling is used, such as when experimentalAutoDetectLongPolling or experimentalForceLongPolling is set to true.
For convenience, here is the documentation for the new experimentalLongPollingOptions.timeoutSeconds property, copied from this PR's code:
The desired maximum timeout interval, in seconds, to complete a long-polling GET response. Valid values are between 5 and 30, inclusive. Floating point values are allowed and will be rounded to the nearest millisecond.
By default, when long-polling is used the "hanging GET" request sent by the client times out after 30 seconds. To request a different timeout from the server, set this setting with the desired timeout.
Changing the default timeout may be useful, for example, if the buffering proxy that necessitated enabling long-polling in the first place has a shorter timeout for hanging GET requests, in which case setting the long-polling timeout to a shorter value, such as 25 seconds, may fix prematurely-closed hanging GET requests.
Below is an example that changes the long-polling "hanging get" timeout from the default (30 seconds) to 25 seconds:
const db = initializeFirestore(app, { experimentalAutoDetectLongPolling: true, experimentalLongPollingOptions: { timeoutSeconds: 25 } });
Googlers see b/266868871
Fixes: #6987