indexeddbshim 19.0.4 → 19.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "indexeddbshim",
3
- "version": "19.0.4",
3
+ "version": "19.0.5",
4
4
  "type": "module",
5
5
  "author": "Parashuram <code@nparashuram.com>",
6
6
  "contributors": [
@@ -297,6 +297,10 @@ IDBTransaction.prototype.__executeRequests = function () {
297
297
  let q,
298
298
  i = -1;
299
299
 
300
+ // On a standard driver, `keepAliveAndWait` issues a SQL query, which
301
+ // is a macrotask. Otherwise it issues ten microtasks.
302
+ const keepAliveAttempts = isStandardDriver ? 1 : 10;
303
+
300
304
  /**
301
305
  * A continuation that must still be able to observe the
302
306
  * transaction as safe to extend (e.g., re-checking whether an
@@ -332,9 +336,9 @@ IDBTransaction.prototype.__executeRequests = function () {
332
336
  });
333
337
  } catch (err) {
334
338
  // The driver has already finalized the transaction (or otherwise
335
- // rejected the call) -- nothing left to hold open, so fall back
336
- // to a plain microtask hop for the continuation itself.
337
- queueMicrotask(cb);
339
+ // rejected the call) -- nothing left to hold open. We explicitly
340
+ // abort the transaction here.
341
+ me.__abortTransaction(/** @type {Error|DOMException} */ (err));
338
342
  }
339
343
  }
340
344
 
@@ -530,9 +534,11 @@ IDBTransaction.prototype.__executeRequests = function () {
530
534
  * consumer of that same handler (e.g. one that resolves a
531
535
  * promise from within `onsuccess` and only attaches `oncomplete`
532
536
  * afterward) ever gets a turn to run, so it can miss `complete`
533
- * entirely. `readonly` requests don't hold a real SQL
534
- * transaction open, though, so there's no file-lock/connection
535
- * collision risk in waiting the same bounded amount here.
537
+ * afterward) ever gets a turn to run, so it can miss `complete`
538
+ * entirely. On a non-standard driver, `readonly` requests don't hold
539
+ * a real SQL transaction open, so there's no file-lock/connection
540
+ * collision risk. On a standard driver, the wait now issues real SQL
541
+ * inside the read transaction, so this does carry a slight risk.
536
542
  * @param {number} attemptsLeft
537
543
  * @returns {void}
538
544
  */
@@ -567,7 +573,7 @@ IDBTransaction.prototype.__executeRequests = function () {
567
573
  }
568
574
  i++;
569
575
  if (i >= me.__requests.length) {
570
- checkQueueEntry(10);
576
+ checkQueueEntry(keepAliveAttempts);
571
577
  return;
572
578
  }
573
579
  runQueuedRequest();
@@ -604,7 +610,7 @@ IDBTransaction.prototype.__executeRequests = function () {
604
610
  }
605
611
  i++;
606
612
  if (i >= me.__requests.length) {
607
- checkQueueEntry(10);
613
+ checkQueueEntry(keepAliveAttempts);
608
614
  return;
609
615
  }
610
616
  keepAliveAndWait(() => {