diff --git a/.changeset/long-lemons-change.md b/.changeset/long-lemons-change.md new file mode 100644 index 00000000000..da79973d1eb --- /dev/null +++ b/.changeset/long-lemons-change.md @@ -0,0 +1,6 @@ +--- +'@firebase/firestore': minor +'firebase': minor +--- + +Enabled long-polling networking mode auto detection by default. It can be explicitly disabled by setting `FirestoreSettings.experimentalForceLongPolling` to `false`. diff --git a/docs-devsite/firestore_.firestoresettings.md b/docs-devsite/firestore_.firestoresettings.md index d5beb7e03c7..2ca277d9b45 100644 --- a/docs-devsite/firestore_.firestoresettings.md +++ b/docs-devsite/firestore_.firestoresettings.md @@ -23,7 +23,7 @@ export declare interface FirestoreSettings | Property | Type | Description | | --- | --- | --- | | [cacheSizeBytes](./firestore_.firestoresettings.md#firestoresettingscachesizebytes) | number | NOTE: This field will be deprecated in a future major release. Use cache field instead to specify cache size, and other cache configurations.An approximate cache size threshold for the on-disk data. If the cache grows beyond this size, Firestore will start removing data that hasn't been recently used. The size is not a guarantee that the cache will stay below that size, only that if the cache exceeds the given size, cleanup will be attempted.The default value is 40 MB. The threshold must be set to at least 1 MB, and can be set to CACHE_SIZE_UNLIMITED to disable garbage collection. | -| [experimentalAutoDetectLongPolling](./firestore_.firestoresettings.md#firestoresettingsexperimentalautodetectlongpolling) | boolean | Configures the SDK's underlying transport (WebChannel) to automatically detect if long-polling should be used. This is very similar to experimentalForceLongPolling, but only uses long-polling if required.This setting will likely be enabled by default in future releases and cannot be combined with experimentalForceLongPolling. | +| [experimentalAutoDetectLongPolling](./firestore_.firestoresettings.md#firestoresettingsexperimentalautodetectlongpolling) | boolean | Configures the SDK's underlying transport (WebChannel) to automatically detect if long-polling should be used. This is very similar to experimentalForceLongPolling, but only uses long-polling if required.After having had a default value of false since its inception in 2019, the default value of this setting was changed in mid-2023 to true. That is, auto-detection of long polling is now enabled by default. To disable it, set this setting to false, and please open a GitHub issue to share the problems that motivated you disabling long-polling auto-detection. | | [experimentalForceLongPolling](./firestore_.firestoresettings.md#firestoresettingsexperimentalforcelongpolling) | boolean | Forces the SDK’s underlying network transport (WebChannel) to use long-polling. Each response from the backend will be closed immediately after the backend sends data (by default responses are kept open in case the backend has more data to send). This avoids incompatibility issues with certain proxies, antivirus software, etc. that incorrectly buffer traffic indefinitely. Use of this option will cause some performance degradation though.This setting cannot be used with experimentalAutoDetectLongPolling and may be removed in a future release. If you find yourself using it to work around a specific network reliability issue, please tell us about it in https://github.com/firebase/firebase-js-sdk/issues/1674. | | [experimentalLongPollingOptions](./firestore_.firestoresettings.md#firestoresettingsexperimentallongpollingoptions) | [ExperimentalLongPollingOptions](./firestore_.experimentallongpollingoptions.md#experimentallongpollingoptions_interface) | Options that configure the SDK’s underlying network transport (WebChannel) when long-polling is used.These options are only used if experimentalForceLongPolling is true or if experimentalAutoDetectLongPolling is true and the auto-detection determined that long-polling was needed. Otherwise, these options have no effect. | | [host](./firestore_.firestoresettings.md#firestoresettingshost) | string | The hostname to connect to. | @@ -49,7 +49,7 @@ cacheSizeBytes?: number; Configures the SDK's underlying transport (WebChannel) to automatically detect if long-polling should be used. This is very similar to `experimentalForceLongPolling`, but only uses long-polling if required. -This setting will likely be enabled by default in future releases and cannot be combined with `experimentalForceLongPolling`. +After having had a default value of `false` since its inception in 2019, the default value of this setting was changed in mid-2023 to `true`. That is, auto-detection of long polling is now enabled by default. To disable it, set this setting to `false`, and please open a GitHub issue to share the problems that motivated you disabling long-polling auto-detection. Signature: diff --git a/packages/firestore/src/api/settings.ts b/packages/firestore/src/api/settings.ts index babf9499387..8cdc1dc0657 100644 --- a/packages/firestore/src/api/settings.ts +++ b/packages/firestore/src/api/settings.ts @@ -89,8 +89,11 @@ export interface FirestoreSettings extends LiteSettings { * detect if long-polling should be used. This is very similar to * `experimentalForceLongPolling`, but only uses long-polling if required. * - * This setting will likely be enabled by default in future releases and - * cannot be combined with `experimentalForceLongPolling`. + * After having had a default value of `false` since its inception in 2019, + * the default value of this setting was changed in mid-2023 to `true`. That + * is, auto-detection of long polling is now enabled by default. To disable + * it, set this setting to `false`, and please open a GitHub issue to share + * the problems that motivated you disabling long-polling auto-detection. */ experimentalAutoDetectLongPolling?: boolean; diff --git a/packages/firestore/src/lite-api/settings.ts b/packages/firestore/src/lite-api/settings.ts index 3a731689e83..97d4efd8aee 100644 --- a/packages/firestore/src/lite-api/settings.ts +++ b/packages/firestore/src/lite-api/settings.ts @@ -46,7 +46,7 @@ const MIN_LONG_POLLING_TIMEOUT_SECONDS = 5; const MAX_LONG_POLLING_TIMEOUT_SECONDS = 30; // Whether long-polling auto-detected is enabled by default. -const DEFAULT_AUTO_DETECT_LONG_POLLING = false; +const DEFAULT_AUTO_DETECT_LONG_POLLING = true; /** * Specifies custom configurations for your Cloud Firestore instance. diff --git a/packages/firestore/test/unit/api/database.test.ts b/packages/firestore/test/unit/api/database.test.ts index 94b67257d2a..ddae011b3cb 100644 --- a/packages/firestore/test/unit/api/database.test.ts +++ b/packages/firestore/test/unit/api/database.test.ts @@ -279,10 +279,10 @@ describe('Settings', () => { ); }); - it('long polling should be disabled by default', () => { + it('long polling should be in auto-detect mode by default', () => { // Use a new instance of Firestore in order to configure settings. const db = newTestFirestore(); - expect(db._getSettings().experimentalAutoDetectLongPolling).to.be.false; + expect(db._getSettings().experimentalAutoDetectLongPolling).to.be.true; expect(db._getSettings().experimentalForceLongPolling).to.be.false; }); @@ -306,13 +306,13 @@ describe('Settings', () => { expect(db._getSettings().experimentalForceLongPolling).to.be.false; }); - it('long polling should be disabled if force=false', () => { + it('long polling should be in auto-detect mode if force=false', () => { // Use a new instance of Firestore in order to configure settings. const db = newTestFirestore(); db._setSettings({ experimentalForceLongPolling: false }); - expect(db._getSettings().experimentalAutoDetectLongPolling).to.be.false; + expect(db._getSettings().experimentalAutoDetectLongPolling).to.be.true; expect(db._getSettings().experimentalForceLongPolling).to.be.false; });