Skip to content

Commit

Permalink
Fix more compiler errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinnot committed Jan 12, 2018
1 parent 6cdf964 commit c0c3c63
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions packages/firestore/src/remote/persistent_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export abstract class PersistentStream<
this.startStream(token);
},
(error: Error) => {
this.queue.schedule(() => {
this.queue.schedule(async () => {
if (this.state !== PersistentStreamState.Stopped) {
// Stream can be stopped while waiting for authorization.
const rpcError = new FirestoreError(
Expand Down Expand Up @@ -415,7 +415,7 @@ export abstract class PersistentStream<
stream: Stream<SendType, ReceiveType>,
fn: () => Promise<void>
) => {
this.queue.schedule(() => {
this.queue.schedule(async () => {
// Only raise events if the stream instance has not changed
if (this.stream === stream) {
return fn();
Expand Down
13 changes: 7 additions & 6 deletions packages/firestore/src/remote/remote_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ export class RemoteStore {
}
}

private onWatchStreamChange(
private async onWatchStreamChange(
watchChange: WatchChange,
snapshotVersion: SnapshotVersion
): Promise<void> {
Expand Down Expand Up @@ -545,7 +545,8 @@ export class RemoteStore {
const error = watchChange.cause!;
let promiseChain = Promise.resolve();
watchChange.targetIds.forEach(targetId => {
promiseChain = promiseChain.then(() => {
promiseChain = promiseChain.then(async () => {
// A watched target might have been removed already.
if (objUtils.contains(this.listenTargets, targetId)) {
delete this.listenTargets[targetId];
return this.syncEngine.rejectListen(targetId, error);
Expand All @@ -564,7 +565,7 @@ export class RemoteStore {
* Notifies that there are new mutations to process in the queue. This is
* typically called by SyncEngine after it has sent mutations to LocalStore.
*/
fillWritePipeline(): Promise<void> {
async fillWritePipeline(): Promise<void> {
if (this.canWriteMutations()) {
return this.localStore
.nextMutationBatch(this.lastBatchSeen)
Expand Down Expand Up @@ -696,7 +697,7 @@ export class RemoteStore {
});
}

private onWriteStreamClose(error?: FirestoreError): Promise<void> {
private async onWriteStreamClose(error?: FirestoreError): Promise<void> {
assert(
this.isNetworkEnabled(),
'onWriteStreamClose() should only be called when the network is enabled'
Expand Down Expand Up @@ -732,7 +733,7 @@ export class RemoteStore {
// No pending writes, nothing to do
}

private handleHandshakeError(error: FirestoreError): Promise<void> {
private async handleHandshakeError(error: FirestoreError): Promise<void> {
// Reset the token if it's a permanent error or the error code is
// ABORTED, signaling the write stream is no longer valid.
if (isPermanentError(error.code) || error.code === Code.ABORTED) {
Expand All @@ -750,7 +751,7 @@ export class RemoteStore {
// just retry with exponential backoff.
}

private handleWriteError(error: FirestoreError): Promise<void> {
private async handleWriteError(error: FirestoreError): Promise<void> {
if (isPermanentError(error.code)) {
// This was a permanent error, the request itself was the problem
// so it's not going to succeed if we resend it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ apiDescribe('Server Timestamps', persistence => {
it('work via transaction set()', () => {
return withTestSetup(() => {
return docRef.firestore
.runTransaction(txn => {
.runTransaction(async txn => {
txn.set(docRef, setData);
})
.then(() => waitForRemoteEvent());
Expand All @@ -152,7 +152,7 @@ apiDescribe('Server Timestamps', persistence => {
return withTestSetup(() => {
return writeInitialData()
.then(() =>
docRef.firestore.runTransaction(txn => {
docRef.firestore.runTransaction(async txn => {
txn.update(docRef, updateData);
})
)
Expand All @@ -176,7 +176,7 @@ apiDescribe('Server Timestamps', persistence => {
it('fail via transaction update() on nonexistent document.', () => {
return withTestSetup(() => {
return docRef.firestore
.runTransaction(txn => {
.runTransaction(async txn => {
txn.update(docRef, updateData);
})
.then(
Expand Down
10 changes: 5 additions & 5 deletions packages/firestore/test/integration/api/transactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ apiDescribe('Database transactions', persistence => {
.then(snapshot => {
expect(snapshot).to.exist;
expect(snapshot.data()['foo']).to.equal('bar');
return db.runTransaction(transaction => {
return db.runTransaction(async transaction => {
transaction.delete(doc);
});
})
Expand Down Expand Up @@ -185,7 +185,7 @@ apiDescribe('Database transactions', persistence => {
return integrationHelpers.withTestDb(persistence, db => {
const doc = db.collection('towns').doc();
return db
.runTransaction(transaction => {
.runTransaction(async transaction => {
transaction.set(doc, { a: 'b' }).set(doc, { c: 'd' });
})
.then(() => {
Expand All @@ -202,7 +202,7 @@ apiDescribe('Database transactions', persistence => {
return integrationHelpers.withTestDb(persistence, db => {
const doc = db.collection('towns').doc();
return db
.runTransaction(transaction => {
.runTransaction(async transaction => {
transaction.set(doc, { a: 'b', nested: { a: 'b' } }).set(
doc,
{ c: 'd', nested: { c: 'd' } },
Expand Down Expand Up @@ -354,7 +354,7 @@ apiDescribe('Database transactions', persistence => {
return integrationHelpers.withTestDb(persistence, db => {
const doc = db.collection('counters').doc();
return db
.runTransaction(transaction => {
.runTransaction(async transaction => {
transaction.set(doc, initialData);
transaction.update(
doc,
Expand Down Expand Up @@ -533,7 +533,7 @@ apiDescribe('Database transactions', persistence => {

it('are successful with no transaction operations', () => {
return integrationHelpers.withTestDb(persistence, db => {
return db.runTransaction(txn => {});
return db.runTransaction(async txn => {});
});
});

Expand Down
8 changes: 4 additions & 4 deletions packages/firestore/test/integration/api/validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function validationIt(
testFunction: (db: firestore.FirebaseFirestore) => void | Promise<any>
) {
it(message, () => {
return withTestDb(persistence, db => {
return withTestDb(persistence, async db => {
const maybePromise = testFunction(db);
if (maybePromise) {
return maybePromise;
Expand Down Expand Up @@ -339,7 +339,7 @@ apiDescribe('Validation:', persistence => {
.commit();
})
.then(() => {
return ref.firestore.runTransaction(txn => {
return ref.firestore.runTransaction(async txn => {
// Note ref2 does not exist at this point so set that and update ref.
txn.update(ref, data);
txn.set(ref2, data);
Expand Down Expand Up @@ -462,7 +462,7 @@ apiDescribe('Validation:', persistence => {
const reason =
'Provided document reference is from a different Firestore instance.';
const data = { foo: 1 };
return db.runTransaction(txn => {
return db.runTransaction(async txn => {
expect(() => txn.get(badRef)).to.throw(reason);
expect(() => txn.set(badRef, data)).to.throw(reason);
expect(() => txn.update(badRef, data)).to.throw(reason);
Expand Down Expand Up @@ -750,7 +750,7 @@ function expectWriteToFail(
);
}

return docRef.firestore.runTransaction(txn => {
return docRef.firestore.runTransaction(async txn => {
if (includeSets) {
expect(() => txn.set(docRef, data)).to.throw(error('Transaction.set'));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/test/unit/specs/spec_test_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ abstract class TestRunner {
});
}

private doFailWrite(writeFailure: SpecWriteFailure): Promise<void> {
private async doFailWrite(writeFailure: SpecWriteFailure): Promise<void> {
const specError: SpecError = writeFailure.error;
const error = new FirestoreError(
mapCodeFromRpcCode(specError.code),
Expand Down

0 comments on commit c0c3c63

Please sign in to comment.