Skip to content

Commit 27ded6b

Browse files
Raise an error for enablePersistence() in memory-only build
1 parent ec1471c commit 27ded6b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/firestore/src/core/component_provider.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { Platform } from '../platform/platform';
3131
import { Datastore } from '../remote/datastore';
3232
import { User } from '../auth/user';
3333
import { PersistenceSettings } from './firestore_client';
34-
import { debugAssert } from '../util/assert';
34+
import { debugAssert, hardAssert } from '../util/assert';
3535
import { GarbageCollectionScheduler, Persistence } from '../local/persistence';
3636
import { Code, FirestoreError } from '../util/error';
3737
import { OnlineStateSource } from './types';
@@ -133,10 +133,12 @@ export class MemoryComponentProvider implements ComponentProvider {
133133
}
134134

135135
createPersistence(cfg: ComponentConfiguration): Persistence {
136-
debugAssert(
137-
!cfg.persistenceSettings.durable,
138-
'Can only start memory persistence'
139-
);
136+
if (cfg.persistenceSettings.durable) {
137+
throw new FirestoreError(
138+
Code.FAILED_PRECONDITION,
139+
MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE
140+
);
141+
}
140142
return new MemoryPersistence(MemoryEagerDelegate.factory);
141143
}
142144

0 commit comments

Comments
 (0)