Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f062376
set experimentalAutoDetectLongPolling default value to true
dconeybe Apr 20, 2023
65d5e9c
changeset
dconeybe Apr 20, 2023
959c0e7
Firestore: database.test.ts: add unit tests for long polling settings…
dconeybe Apr 20, 2023
7f52fe4
Merge branch 'LongPollingSettingsTests' into AutoDetectLongPollingEna…
dconeybe Apr 20, 2023
ac752d1
Update documentation of experimentalAutoDetectLongPolling to document…
dconeybe Apr 20, 2023
8218910
reword changeset
dconeybe Apr 20, 2023
09d6f31
yarn docgen devsite
dconeybe Apr 20, 2023
40f2018
Merge remote-tracking branch 'origin/master' into AutoDetectLongPolli…
dconeybe Apr 20, 2023
eb854dc
Firestore: settings.ts: very minor refactor of long-polling logic.
dconeybe Apr 20, 2023
75b2c9b
Merge branch 'LongPollingLogicTweak' into AutoDetectLongPollingEnable…
dconeybe Apr 20, 2023
ef8665f
invert negative 'if' statement and ensure that experimentalAutoDetect…
dconeybe Apr 20, 2023
e0e0741
Merge branch 'LongPollingLogicTweak' into AutoDetectLongPollingEnable…
dconeybe Apr 20, 2023
8e84d43
add DEFAULT_AUTO_DETECT_LONG_POLLING and coerce to boolean
dconeybe Apr 20, 2023
3e2be99
Firestore: database.test.ts: add tests for coercing experimentalForce…
dconeybe Apr 20, 2023
d8fccbe
yarn prettier
dconeybe Apr 20, 2023
7427858
tweak unit test descriptions
dconeybe Apr 20, 2023
81a61b4
add `// eslint-disable-next-line @typescript-eslint/no-explicit-any` …
dconeybe Apr 20, 2023
10aba36
Merge branch 'LongPollingCoerceToBooleanTests' into LongPollingLogicT…
dconeybe Apr 20, 2023
17519c3
invert a negative 'if' statement
dconeybe Apr 20, 2023
7522b43
Merge remote-tracking branch 'remotes/origin/dconeybe/LongPollingLogi…
dconeybe Apr 20, 2023
c27a49a
Merge remote-tracking branch 'origin/master' into LongPollingLogicTweak
dconeybe Apr 20, 2023
a9696c5
Merge branch 'LongPollingLogicTweak' into AutoDetectLongPollingEnable…
dconeybe Apr 20, 2023
b64dc66
Merge remote-tracking branch 'origin/master' into AutoDetectLongPolli…
dconeybe Apr 21, 2023
f166d1d
tweak api docs for experimentalAutoDetectLongPolling, as suggested in…
dconeybe Apr 21, 2023
e58f70b
Merge remote-tracking branch 'origin/master' into AutoDetectLongPolli…
dconeybe May 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add DEFAULT_AUTO_DETECT_LONG_POLLING and coerce to boolean
  • Loading branch information
dconeybe committed Apr 20, 2023
commit 8e84d43a5759c50470f83d3898843e78690101d0
21 changes: 12 additions & 9 deletions packages/firestore/src/lite-api/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { validateIsNotUsedTogether } from '../util/input_validation';
export const DEFAULT_HOST = 'firestore.googleapis.com';
export const DEFAULT_SSL = true;

const DEFAULT_AUTO_DETECT_LONG_POLLING = false;

/**
* Specifies custom configurations for your Cloud Firestore instance.
* You must set these before invoking any other methods.
Expand Down Expand Up @@ -130,17 +132,18 @@ export class FirestoreSettingsImpl {
settings.experimentalAutoDetectLongPolling
);

if (settings.experimentalForceLongPolling) {
this.experimentalForceLongPolling = true;
this.experimentalForceLongPolling = !!settings.experimentalForceLongPolling;

if (this.experimentalForceLongPolling) {
this.experimentalAutoDetectLongPolling = false;
} else if (settings.experimentalAutoDetectLongPolling !== undefined) {
// For backwards compatibility, coerce the value to boolean even though
// the TypeScript compiler has narrowed the type to boolean already.
// noinspection PointlessBooleanExpressionJS
this.experimentalAutoDetectLongPolling =
!!settings.experimentalAutoDetectLongPolling;
} else {
this.experimentalForceLongPolling = false;
if (settings.experimentalAutoDetectLongPolling === undefined) {
this.experimentalAutoDetectLongPolling = false;
} else {
this.experimentalAutoDetectLongPolling =
settings.experimentalAutoDetectLongPolling;
}
this.experimentalAutoDetectLongPolling = DEFAULT_AUTO_DETECT_LONG_POLLING;
}

this.useFetchStreams = !!settings.useFetchStreams;
Expand Down
36 changes: 36 additions & 0 deletions packages/firestore/test/unit/api/database.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,42 @@ describe('Settings', () => {
expect(db._getSettings().experimentalForceLongPolling).to.be.false;
});

it('long polling autoDetect=[something truthy] is corced to true', () => {
// Use a new instance of Firestore in order to configure settings.
const db = newTestFirestore();
db._setSettings({
experimentalAutoDetectLongPolling: 1 as any,
});
expect(db._getSettings().experimentalAutoDetectLongPolling).to.be.true;
});

it('long polling autoDetect=[something falsy] is corced to false', () => {
// Use a new instance of Firestore in order to configure settings.
const db = newTestFirestore();
db._setSettings({
experimentalAutoDetectLongPolling: 0 as any,
});
expect(db._getSettings().experimentalAutoDetectLongPolling).to.be.false;
});

it('long polling force=[something truthy] is corced to true', () => {
// Use a new instance of Firestore in order to configure settings.
const db = newTestFirestore();
db._setSettings({
experimentalForceLongPolling: "I am truthy" as any,
});
expect(db._getSettings().experimentalForceLongPolling).to.be.true;
});

it('long polling force=[something falsy] is corced to false', () => {
// Use a new instance of Firestore in order to configure settings.
const db = newTestFirestore();
db._setSettings({
experimentalForceLongPolling: NaN as any,
});
expect(db._getSettings().experimentalForceLongPolling).to.be.false;
});

it('gets settings from useEmulator', () => {
// Use a new instance of Firestore in order to configure settings.
const db = newTestFirestore();
Expand Down