diff --git a/.changeset/eighty-tomatoes-trade.md b/.changeset/eighty-tomatoes-trade.md new file mode 100644 index 00000000000..26b2fb2cc21 --- /dev/null +++ b/.changeset/eighty-tomatoes-trade.md @@ -0,0 +1,6 @@ +--- +"@firebase/firestore": patch +"firebase": patch +--- + +Fix an issue where localCache is not copied as part of Settings. diff --git a/docs-devsite/firestore_.firestoresettings.md b/docs-devsite/firestore_.firestoresettings.md index 89444273b64..6d24d583175 100644 --- a/docs-devsite/firestore_.firestoresettings.md +++ b/docs-devsite/firestore_.firestoresettings.md @@ -28,7 +28,7 @@ export declare interface FirestoreSettings | [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. | | [ignoreUndefinedProperties](./firestore_.firestoresettings.md#firestoresettingsignoreundefinedproperties) | boolean | Whether to skip nested properties that are set to undefined during object serialization. If set to true, these properties are skipped and not written to Firestore. If set to false or omitted, the SDK throws an exception when it encounters properties of type undefined. | -| [localCache](./firestore_.firestoresettings.md#firestoresettingslocalcache) | [FirestoreLocalCache](./firestore_.md#firestorelocalcache) | Specifies the cache used by the SDK. Available options are MemoryLocalCache and IndexedDbLocalCache, each with different configuration options.When unspecified, MemoryLocalCache will be used by default.NOTE: setting this field and cacheSizeBytes at the same time will throw exception during SDK initialization. Instead, using the configuration in the FirestoreLocalCache object to specify the cache size. | +| [localCache](./firestore_.firestoresettings.md#firestoresettingslocalcache) | [FirestoreLocalCache](./firestore_.md#firestorelocalcache) | Specifies the cache used by the SDK. Available options are MemoryLocalCache and PersistentLocalCache, each with different configuration options.When unspecified, MemoryLocalCache will be used by default.NOTE: setting this field and cacheSizeBytes at the same time will throw exception during SDK initialization. Instead, using the configuration in the FirestoreLocalCache object to specify the cache size. | | [ssl](./firestore_.firestoresettings.md#firestoresettingsssl) | boolean | Whether to use SSL when connecting. | ## FirestoreSettings.cacheSizeBytes @@ -107,7 +107,7 @@ ignoreUndefinedProperties?: boolean; ## FirestoreSettings.localCache -Specifies the cache used by the SDK. Available options are `MemoryLocalCache` and `IndexedDbLocalCache`, each with different configuration options. +Specifies the cache used by the SDK. Available options are `MemoryLocalCache` and `PersistentLocalCache`, each with different configuration options. When unspecified, `MemoryLocalCache` will be used by default. diff --git a/docs-devsite/firestore_.md b/docs-devsite/firestore_.md index a0c52be3bc0..61881a3222a 100644 --- a/docs-devsite/firestore_.md +++ b/docs-devsite/firestore_.md @@ -437,7 +437,7 @@ If the final path has an odd number of segments and does not point to a document > Warning: This API is now obsolete. > -> This function will be removed in a future major release. Instead, set `FirestoreSettings.cache` to an instance of `IndexedDbLocalCache` to turn on IndexedDb cache. Calling this function when `FirestoreSettings.cache` is already specified will throw an exception. +> This function will be removed in a future major release. Instead, set `FirestoreSettings.localCache` to an instance of `PersistentLocalCache` to turn on IndexedDb cache. Calling this function when `FirestoreSettings.localCache` is already specified will throw an exception. > Attempts to enable persistent storage, if possible. @@ -475,7 +475,7 @@ A `Promise` that represents successfully enabling persistent storage. > Warning: This API is now obsolete. > -> This function will be removed in a future major release. Instead, set `FirestoreSettings.cache` to an instance of `IndexedDbLocalCache` to turn on indexeddb cache. Calling this function when `FirestoreSettings.cache` is already specified will throw an exception. +> This function will be removed in a future major release. Instead, set `FirestoreSettings.localCache` to an instance of `PersistentLocalCache` to turn on indexeddb cache. Calling this function when `FirestoreSettings.localCache` is already specified will throw an exception. > Attempts to enable multi-tab persistent storage, if possible. If enabled across all tabs, all operations share access to local persistence, including shared execution of queries and latency-compensated local document updates across all connected instances. diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index e4d0bdd4289..32f2aee8a7e 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -291,13 +291,13 @@ export function configureFirestore(firestore: Firestore): void { databaseInfo ); if ( - settings.cache?._offlineComponentProvider && - settings.cache?._onlineComponentProvider + settings.localCache?._offlineComponentProvider && + settings.localCache?._onlineComponentProvider ) { firestore._firestoreClient._uninitializedComponentsProvider = { - _offlineKind: settings.cache.kind, - _offline: settings.cache._offlineComponentProvider, - _online: settings.cache._onlineComponentProvider + _offlineKind: settings.localCache.kind, + _offline: settings.localCache._offlineComponentProvider, + _online: settings.localCache._onlineComponentProvider }; } } @@ -327,8 +327,8 @@ export function configureFirestore(firestore: Firestore): void { * persistence. * @returns A `Promise` that represents successfully enabling persistent storage. * @deprecated This function will be removed in a future major release. Instead, set - * `FirestoreSettings.cache` to an instance of `IndexedDbLocalCache` to - * turn on IndexedDb cache. Calling this function when `FirestoreSettings.cache` + * `FirestoreSettings.localCache` to an instance of `PersistentLocalCache` to + * turn on IndexedDb cache. Calling this function when `FirestoreSettings.localCache` * is already specified will throw an exception. */ export function enableIndexedDbPersistence( @@ -387,8 +387,8 @@ export function enableIndexedDbPersistence( * @returns A `Promise` that represents successfully enabling persistent * storage. * @deprecated This function will be removed in a future major release. Instead, set - * `FirestoreSettings.cache` to an instance of `IndexedDbLocalCache` to - * turn on indexeddb cache. Calling this function when `FirestoreSettings.cache` + * `FirestoreSettings.localCache` to an instance of `PersistentLocalCache` to + * turn on indexeddb cache. Calling this function when `FirestoreSettings.localCache` * is already specified will throw an exception. */ export function enableMultiTabIndexedDbPersistence( diff --git a/packages/firestore/src/api/settings.ts b/packages/firestore/src/api/settings.ts index 40c0df79fa2..b47017bbc2e 100644 --- a/packages/firestore/src/api/settings.ts +++ b/packages/firestore/src/api/settings.ts @@ -60,7 +60,7 @@ export interface FirestoreSettings extends LiteSettings { /** * Specifies the cache used by the SDK. Available options are `MemoryLocalCache` - * and `IndexedDbLocalCache`, each with different configuration options. + * and `PersistentLocalCache`, each with different configuration options. * * When unspecified, `MemoryLocalCache` will be used by default. * diff --git a/packages/firestore/src/lite-api/settings.ts b/packages/firestore/src/lite-api/settings.ts index 97d4efd8aee..ebfbb239bcc 100644 --- a/packages/firestore/src/lite-api/settings.ts +++ b/packages/firestore/src/lite-api/settings.ts @@ -104,7 +104,7 @@ export class FirestoreSettingsImpl { readonly ignoreUndefinedProperties: boolean; readonly useFetchStreams: boolean; - readonly cache?: FirestoreLocalCache; + readonly localCache?: FirestoreLocalCache; // Can be a google-auth-library or gapi client. // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -127,7 +127,7 @@ export class FirestoreSettingsImpl { this.credentials = settings.credentials; this.ignoreUndefinedProperties = !!settings.ignoreUndefinedProperties; - this.cache = settings.localCache; + this.localCache = settings.localCache; if (settings.cacheSizeBytes === undefined) { this.cacheSizeBytes = LRU_DEFAULT_CACHE_SIZE_BYTES;