Skip to content
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: Add ability to configure long polling timeout #7176

Merged
merged 31 commits into from
May 1, 2023

Conversation

dconeybe
Copy link
Contributor

@dconeybe dconeybe commented Mar 31, 2023

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

@dconeybe dconeybe self-assigned this Mar 31, 2023
@changeset-bot
Copy link

changeset-bot bot commented Mar 31, 2023

🦋 Changeset detected

Latest commit: 3bd125d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/firestore Minor
firebase Minor
@firebase/firestore-compat Patch

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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 31, 2023

Size Report 1

Affected Products

  • @firebase/firestore

    TypeBase (5a2ceb0)Merge (057eafd)Diff
    browser285 kB286 kB+1.01 kB (+0.4%)
    esm5354 kB355 kB+1.03 kB (+0.3%)
    main567 kB568 kB+1.48 kB (+0.3%)
    module285 kB286 kB+1.01 kB (+0.4%)
    react-native285 kB286 kB+1.01 kB (+0.4%)
  • @firebase/firestore-lite

    TypeBase (5a2ceb0)Merge (057eafd)Diff
    browser87.5 kB88.3 kB+817 B (+0.9%)
    esm5105 kB106 kB+842 B (+0.8%)
    main149 kB151 kB+1.48 kB (+1.0%)
    module87.5 kB88.3 kB+817 B (+0.9%)
    react-native87.7 kB88.5 kB+817 B (+0.9%)
  • @firebase/webchannel-wrapper

    TypeBase (5a2ceb0)Merge (057eafd)Diff
    esm555.2 kB55.4 kB+239 B (+0.4%)
    main65.1 kB65.4 kB+258 B (+0.4%)
    module52.9 kB53.1 kB+147 B (+0.3%)
  • bundle

    12 size changes

    TypeBase (5a2ceb0)Merge (057eafd)Diff
    firestore (Persistence)298 kB300 kB+1.17 kB (+0.4%)
    firestore (Query Cursors)237 kB238 kB+1.17 kB (+0.5%)
    firestore (Query)234 kB235 kB+1.17 kB (+0.5%)
    firestore (Read data once)222 kB223 kB+1.17 kB (+0.5%)
    firestore (Realtime updates)224 kB225 kB+1.17 kB (+0.5%)
    firestore (Transaction)201 kB202 kB+1.17 kB (+0.6%)
    firestore (Write data)201 kB202 kB+1.17 kB (+0.6%)
    firestore-lite (Query Cursors)81.7 kB82.5 kB+823 B (+1.0%)
    firestore-lite (Query)77.9 kB78.7 kB+823 B (+1.1%)
    firestore-lite (Read data once)60.0 kB60.8 kB+823 B (+1.4%)
    firestore-lite (Transaction)84.8 kB85.6 kB+823 B (+1.0%)
    firestore-lite (Write data)69.6 kB70.4 kB+823 B (+1.2%)

  • firebase

    TypeBase (5a2ceb0)Merge (057eafd)Diff
    firebase-compat.js772 kB773 kB+1.15 kB (+0.1%)
    firebase-firestore-compat.js338 kB339 kB+1.14 kB (+0.3%)
    firebase-firestore-lite.js94.2 kB95.0 kB+817 B (+0.9%)
    firebase-firestore.js344 kB345 kB+1.16 kB (+0.3%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/oqJyVp0fbr.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 31, 2023

Size Analysis Report 1

This report is too large (542,285 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

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/a209gKbaKT.html

@dconeybe dconeybe changed the title Firestore: add experimentalLongPollingTimeout setting Firestore: Add ability to configure long polling timeout Apr 14, 2023
@dconeybe dconeybe requested a review from ehsannas April 24, 2023 17:51
Copy link
Contributor

@ehsannas ehsannas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tom was right! ;-P

packages/firestore/src/lite-api/settings.ts Outdated Show resolved Hide resolved
@dconeybe dconeybe marked this pull request as ready for review April 27, 2023 19:29
Copy link
Contributor

@hsubox76 hsubox76 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a changeset?

@dconeybe dconeybe requested a review from a team as a code owner April 28, 2023 19:58
@dconeybe
Copy link
Contributor Author

Can you add a changeset?

Done. Thanks for pointing that out.

@dconeybe dconeybe merged commit 8051e4a into master May 1, 2023
@dconeybe dconeybe deleted the dconeybe/LongPollingTimeout branch May 1, 2023 17:26
dconeybe added a commit that referenced this pull request May 8, 2023
This changeset was created by #7176, but its wording neglected to update `idleHttpRequestTimeoutSeconds` to `experimentalLongPollingOptions.timeoutSeconds`. This commit fixes the wording to specify the correct property.
@google-oss-bot google-oss-bot mentioned this pull request May 11, 2023
@firebase firebase locked and limited conversation to collaborators Jun 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FR: respond to long polling after 29 seconds instead of 30, or make it configurable
5 participants