Skip to content

Fix Firestore build #3066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ describe('IndexedDb: allowTabSynchronization', () => {
'clientA',
/* multiClient= */ false,
async db => {
db.injectFailures = true;
db.injectFailures = { updateClientMetadataAndTryBecomePrimary: true };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you planning on making the other clients have the same transaction names? (Obviously they won't have the multitab related transactions, but how will this failure mechanism work anywhere else?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I am also planning to clean up our names before this happens.

await expect(db.start()).to.eventually.be.rejectedWith(
'Failed to obtain exclusive access to the persistence layer.'
);
Expand All @@ -1158,7 +1158,7 @@ describe('IndexedDb: allowTabSynchronization', () => {
'clientA',
/* multiClient= */ true,
async db => {
db.injectFailures = true;
db.injectFailures = { updateClientMetadataAndTryBecomePrimary: true };
await db.start();
await db.shutdown();
}
Expand All @@ -1167,10 +1167,10 @@ describe('IndexedDb: allowTabSynchronization', () => {

it('ignores intermittent IndexedDbTransactionError during lease refresh', async () => {
await withPersistence('clientA', async (db, _, queue) => {
db.injectFailures = true;
db.injectFailures = { updateClientMetadataAndTryBecomePrimary: true };
await queue.runDelayedOperationsEarly(TimerId.ClientMetadataRefresh);
await queue.enqueue(() => {
db.injectFailures = false;
db.injectFailures = undefined;
return db.runTransaction('check success', 'readwrite-primary', () =>
PersistencePromise.resolve()
);
Expand Down
4 changes: 2 additions & 2 deletions packages/firestore/test/unit/specs/spec_test_components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { expect } from 'chai';
export class MockMemoryPersistence extends MemoryPersistence {
injectFailures?: SpecDatabaseFailures;

runTransaction<T>(
async runTransaction<T>(
action: string,
mode: PersistenceTransactionMode,
transactionOperation: (
Expand All @@ -78,7 +78,7 @@ export class MockMemoryPersistence extends MemoryPersistence {
export class MockIndexedDbPersistence extends IndexedDbPersistence {
injectFailures?: SpecDatabaseFailures;

runTransaction<T>(
async runTransaction<T>(
action: string,
mode: PersistenceTransactionMode,
transactionOperation: (
Expand Down
3 changes: 2 additions & 1 deletion packages/firestore/test/unit/specs/spec_test_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,8 @@ export type PersistenceAction =
| 'Lookup mutation documents'
| 'Get target data'
| 'Get new document changes'
| 'Synchronize last document change read time';
| 'Synchronize last document change read time'
| 'updateClientMetadataAndTryBecomePrimary';

/** Specifies failure or success for a list of database actions. */
export type SpecDatabaseFailures = Partial<
Expand Down