dexie 3.2.0-rc.3 → 3.2.1

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.
@@ -4,9 +4,9 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 3.2.0-rc.3, Thu Oct 28 2021
7
+ * Version 3.2.1, Wed Feb 16 2022
8
8
  *
9
- * http://dexie.org
9
+ * https://dexie.org
10
10
  *
11
11
  * Apache License Version 2.0, January 2004, http://www.apache.org/licenses/
12
12
  */
@@ -1221,8 +1221,14 @@ function tempTransaction(db, mode, storeNames, fn) {
1221
1221
  var trans = db._createTransaction(mode, storeNames, db._dbSchema);
1222
1222
  try {
1223
1223
  trans.create();
1224
+ db._state.PR1398_maxLoop = 3;
1224
1225
  }
1225
1226
  catch (ex) {
1227
+ if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {
1228
+ console.warn('Dexie: Need to reopen db');
1229
+ db._close();
1230
+ return db.open().then(() => tempTransaction(db, mode, storeNames, fn));
1231
+ }
1226
1232
  return rejection(ex);
1227
1233
  }
1228
1234
  return trans._promise(mode, (resolve, reject) => {
@@ -1236,7 +1242,7 @@ function tempTransaction(db, mode, storeNames, fn) {
1236
1242
  }
1237
1243
  }
1238
1244
 
1239
- const DEXIE_VERSION = '3.2.0-rc.3';
1245
+ const DEXIE_VERSION = '3.2.1';
1240
1246
  const maxString = String.fromCharCode(65535);
1241
1247
  const minKey = -Infinity;
1242
1248
  const INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
@@ -3737,7 +3743,18 @@ function enterTransactionScope(db, mode, storeNames, parentTransaction, scopeFun
3737
3743
  trans.idbtrans = parentTransaction.idbtrans;
3738
3744
  }
3739
3745
  else {
3740
- trans.create();
3746
+ try {
3747
+ trans.create();
3748
+ db._state.PR1398_maxLoop = 3;
3749
+ }
3750
+ catch (ex) {
3751
+ if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {
3752
+ console.warn('Dexie: Need to reopen db');
3753
+ db._close();
3754
+ return db.open().then(() => enterTransactionScope(db, mode, storeNames, null, scopeFunc));
3755
+ }
3756
+ return rejection(ex);
3757
+ }
3741
3758
  }
3742
3759
  const scopeFuncIsAsync = isAsyncFunction(scopeFunc);
3743
3760
  if (scopeFuncIsAsync) {
@@ -4507,7 +4524,8 @@ class Dexie$1 {
4507
4524
  dbReadyPromise: null,
4508
4525
  cancelOpen: nop,
4509
4526
  openCanceller: null,
4510
- autoSchema: true
4527
+ autoSchema: true,
4528
+ PR1398_maxLoop: 3
4511
4529
  };
4512
4530
  state.dbReadyPromise = new DexiePromise(resolve => {
4513
4531
  state.dbReadyResolve = resolve;