From 0a7142695b5e4da957edfd1424babf80072333e9 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 10 Oct 2019 16:37:07 -0700 Subject: [PATCH 1/2] Improve test hack --- packages/firestore/src/local/simple_db.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/firestore/src/local/simple_db.ts b/packages/firestore/src/local/simple_db.ts index f34e35d4095..133e98c33e8 100644 --- a/packages/firestore/src/local/simple_db.ts +++ b/packages/firestore/src/local/simple_db.ts @@ -273,15 +273,18 @@ export class SimpleDb { objectStores ); try { - // TODO(schmidt-sebastian): Remove this code/comment or find a way to - // make this a test-only setting. - // // Horrible hack to verify that idempotent functions can be run more - // // than once. - // const transactionFnResult = (idempotent && attemptNumber === 1 - // ? transactionFn(transaction) - // : PersistencePromise.resolve({} as T) - // ).next(() => transactionFn(transaction)) const transactionFnResult = transactionFn(transaction) + // TODO(schmidt-sebastian): Remove this code/comment or find a way to + // make this a test-only setting. + // // Horrible hack to verify that idempotent functions can be run more + // // than once. + // .next(result => { + // if (idempotent && attemptNumber == 1) { + // class DOMException {} + // throw new DOMException(); + // } + // return result; + // }) .catch(error => { // Abort the transaction if there was an error. transaction.abort(error); From 58274e60d718205ca6d8cb1196962c0fb8ce6cfa Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 10 Oct 2019 21:43:16 -0700 Subject: [PATCH 2/2] Comment in test hack --- packages/firestore/src/local/simple_db.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/firestore/src/local/simple_db.ts b/packages/firestore/src/local/simple_db.ts index 133e98c33e8..6cf2904f2f9 100644 --- a/packages/firestore/src/local/simple_db.ts +++ b/packages/firestore/src/local/simple_db.ts @@ -257,7 +257,7 @@ export class SimpleDb { async runTransaction( mode: SimpleDbTransactionMode, - objectStores: string[], + objectStores: string[],x transactionFn: (transaction: SimpleDbTransaction) => PersistencePromise ): Promise { const readonly = mode.startsWith('readonly'); @@ -276,15 +276,15 @@ export class SimpleDb { const transactionFnResult = transactionFn(transaction) // TODO(schmidt-sebastian): Remove this code/comment or find a way to // make this a test-only setting. - // // Horrible hack to verify that idempotent functions can be run more - // // than once. - // .next(result => { - // if (idempotent && attemptNumber == 1) { - // class DOMException {} - // throw new DOMException(); - // } - // return result; - // }) + // Horrible hack to verify that idempotent functions can be run more + // than once. + .next(result => { + if (idempotent && attemptNumber == 1) { + class DOMException {} + throw new DOMException(); + } + return result; + }) .catch(error => { // Abort the transaction if there was an error. transaction.abort(error);