Skip to content

Commit e45fea9

Browse files
authored
Firestore: Enable auto-detection of long-polling networking mode (#7236)
1 parent 6feab89 commit e45fea9

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

.changeset/long-lemons-change.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@firebase/firestore': minor
3+
'firebase': minor
4+
---
5+
6+
Enabled long-polling networking mode auto detection by default. It can be explicitly disabled by setting `FirestoreSettings.experimentalForceLongPolling` to `false`.

docs-devsite/firestore_.firestoresettings.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export declare interface FirestoreSettings
2323
| Property | Type | Description |
2424
| --- | --- | --- |
2525
| [cacheSizeBytes](./firestore_.firestoresettings.md#firestoresettingscachesizebytes) | number | NOTE: This field will be deprecated in a future major release. Use <code>cache</code> 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 <code>CACHE_SIZE_UNLIMITED</code> to disable garbage collection. |
26-
| [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 <code>experimentalForceLongPolling</code>, but only uses long-polling if required.<!-- -->This setting will likely be enabled by default in future releases and cannot be combined with <code>experimentalForceLongPolling</code>. |
26+
| [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 <code>experimentalForceLongPolling</code>, but only uses long-polling if required.<!-- -->After having had a default value of <code>false</code> since its inception in 2019, the default value of this setting was changed in mid-2023 to <code>true</code>. That is, auto-detection of long polling is now enabled by default. To disable it, set this setting to <code>false</code>, and please open a GitHub issue to share the problems that motivated you disabling long-polling auto-detection. |
2727
| [experimentalForceLongPolling](./firestore_.firestoresettings.md#firestoresettingsexperimentalforcelongpolling) | boolean | Forces the SDKs 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 <code>experimentalAutoDetectLongPolling</code> 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. |
2828
| [experimentalLongPollingOptions](./firestore_.firestoresettings.md#firestoresettingsexperimentallongpollingoptions) | [ExperimentalLongPollingOptions](./firestore_.experimentallongpollingoptions.md#experimentallongpollingoptions_interface) | Options that configure the SDKs underlying network transport (WebChannel) when long-polling is used.<!-- -->These options are only used if <code>experimentalForceLongPolling</code> is true or if <code>experimentalAutoDetectLongPolling</code> is true and the auto-detection determined that long-polling was needed. Otherwise, these options have no effect. |
2929
| [host](./firestore_.firestoresettings.md#firestoresettingshost) | string | The hostname to connect to. |
@@ -49,7 +49,7 @@ cacheSizeBytes?: number;
4949

5050
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.
5151

52-
This setting will likely be enabled by default in future releases and cannot be combined with `experimentalForceLongPolling`<!-- -->.
52+
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.
5353

5454
<b>Signature:</b>
5555

packages/firestore/src/api/settings.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ export interface FirestoreSettings extends LiteSettings {
8989
* detect if long-polling should be used. This is very similar to
9090
* `experimentalForceLongPolling`, but only uses long-polling if required.
9191
*
92-
* This setting will likely be enabled by default in future releases and
93-
* cannot be combined with `experimentalForceLongPolling`.
92+
* After having had a default value of `false` since its inception in 2019,
93+
* the default value of this setting was changed in mid-2023 to `true`. That
94+
* is, auto-detection of long polling is now enabled by default. To disable
95+
* it, set this setting to `false`, and please open a GitHub issue to share
96+
* the problems that motivated you disabling long-polling auto-detection.
9497
*/
9598
experimentalAutoDetectLongPolling?: boolean;
9699

packages/firestore/src/lite-api/settings.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const MIN_LONG_POLLING_TIMEOUT_SECONDS = 5;
4646
const MAX_LONG_POLLING_TIMEOUT_SECONDS = 30;
4747

4848
// Whether long-polling auto-detected is enabled by default.
49-
const DEFAULT_AUTO_DETECT_LONG_POLLING = false;
49+
const DEFAULT_AUTO_DETECT_LONG_POLLING = true;
5050

5151
/**
5252
* Specifies custom configurations for your Cloud Firestore instance.

packages/firestore/test/unit/api/database.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,10 @@ describe('Settings', () => {
279279
);
280280
});
281281

282-
it('long polling should be disabled by default', () => {
282+
it('long polling should be in auto-detect mode by default', () => {
283283
// Use a new instance of Firestore in order to configure settings.
284284
const db = newTestFirestore();
285-
expect(db._getSettings().experimentalAutoDetectLongPolling).to.be.false;
285+
expect(db._getSettings().experimentalAutoDetectLongPolling).to.be.true;
286286
expect(db._getSettings().experimentalForceLongPolling).to.be.false;
287287
});
288288

@@ -306,13 +306,13 @@ describe('Settings', () => {
306306
expect(db._getSettings().experimentalForceLongPolling).to.be.false;
307307
});
308308

309-
it('long polling should be disabled if force=false', () => {
309+
it('long polling should be in auto-detect mode if force=false', () => {
310310
// Use a new instance of Firestore in order to configure settings.
311311
const db = newTestFirestore();
312312
db._setSettings({
313313
experimentalForceLongPolling: false
314314
});
315-
expect(db._getSettings().experimentalAutoDetectLongPolling).to.be.false;
315+
expect(db._getSettings().experimentalAutoDetectLongPolling).to.be.true;
316316
expect(db._getSettings().experimentalForceLongPolling).to.be.false;
317317
});
318318

0 commit comments

Comments
 (0)