From 0a94d53212a512873518efa52a46978eada75da5 Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Sat, 26 Mar 2022 01:43:59 +0100 Subject: [PATCH] fix: prevent infinite loop when pushing updates Pushing updates would open a readwrite cursor, which would dispatch a new update event and trigger another round of pushing updates. --- src/wrap-idb-value.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wrap-idb-value.ts b/src/wrap-idb-value.ts index b4128c7..8c359c0 100644 --- a/src/wrap-idb-value.ts +++ b/src/wrap-idb-value.ts @@ -234,7 +234,11 @@ function wrapFunction(func: T): Function { } return function (this: any, ...args: Parameters) { - if (func === IDBDatabase.prototype.transaction && args[1] === 'readwrite') { + if ( + func === IDBDatabase.prototype.transaction && + args[1] === 'readwrite' && + args[0] !== LOCAL_CHANGES_STORE + ) { if (!Array.isArray(args[0])) { args[0] = [args[0]]; }