dexie 1.5.0 → 1.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dexie",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "A Minimalistic Wrapper for IndexedDB",
5
5
  "main": "dist/dexie.js",
6
6
  "jsnext:main": "dist/dexie.es6.js",
package/src/Dexie.js CHANGED
@@ -1400,8 +1400,8 @@ export default function Dexie(dbName, options) {
1400
1400
  if (--this._reculock === 0) {
1401
1401
  if (!PSD.global) PSD.lockOwnerFor = null;
1402
1402
  while (this._blockedFuncs.length > 0 && !this._locked()) {
1403
- var fn = this._blockedFuncs.shift();
1404
- try { fn(); } catch (e) { }
1403
+ var fnAndPSD = this._blockedFuncs.shift();
1404
+ try { usePSD(fnAndPSD[1], fnAndPSD[0]); } catch (e) { }
1405
1405
  }
1406
1406
  }
1407
1407
  return this;
@@ -1456,31 +1456,29 @@ export default function Dexie(dbName, options) {
1456
1456
  },
1457
1457
  _promise: function (mode, fn, bWriteLock) {
1458
1458
  var self = this;
1459
- return newScope(function() {
1460
- var p;
1461
- // Read lock always
1462
- if (!self._locked()) {
1463
- p = self.active ? new Promise(function (resolve, reject) {
1459
+ var p = self._locked() ?
1460
+ // Read lock always. Transaction is write-locked. Wait for mutex.
1461
+ new Promise(function (resolve, reject) {
1462
+ self._blockedFuncs.push([function () {
1463
+ self._promise(mode, fn, bWriteLock).then(resolve, reject);
1464
+ }, PSD]);
1465
+ }) :
1466
+ newScope(function() {
1467
+ var p_ = self.active ? new Promise(function (resolve, reject) {
1464
1468
  if (mode === READWRITE && self.mode !== READWRITE)
1465
1469
  throw new exceptions.ReadOnly("Transaction is readonly");
1466
1470
  if (!self.idbtrans && mode) self.create();
1467
1471
  if (bWriteLock) self._lock(); // Write lock if write operation is requested
1468
1472
  fn(resolve, reject, self);
1469
1473
  }) : rejection(new exceptions.TransactionInactive());
1470
- if (self.active && bWriteLock) p.finally(function () {
1474
+ if (self.active && bWriteLock) p_.finally(function () {
1471
1475
  self._unlock();
1472
1476
  });
1473
- } else {
1474
- // Transaction is write-locked. Wait for mutex.
1475
- p = new Promise(function (resolve, reject) {
1476
- self._blockedFuncs.push(function () {
1477
- self._promise(mode, fn, bWriteLock).then(resolve, reject);
1478
- });
1479
- });
1480
- }
1481
- p._lib = true;
1482
- return p.uncaught(dbUncaught);
1483
- });
1477
+ return p_;
1478
+ });
1479
+
1480
+ p._lib = true;
1481
+ return p.uncaught(dbUncaught);
1484
1482
  },
1485
1483
 
1486
1484
  //
@@ -180,3 +180,15 @@ asyncTest ("#323 @gitawego's post. Should not fail unexpectedly on readonly prop
180
180
  }).finally(start);
181
181
 
182
182
  });
183
+
184
+ spawnedTest ("#360 DB unresponsive after multiple Table.update() or Collection.modify()", function* () {
185
+ const NUM_UPDATES = 2000;
186
+ let result = yield db.transaction('rw', db.foo, function* () {
187
+ yield db.foo.put({id: 1, value: 0});
188
+ for (var i=0;i<NUM_UPDATES;++i) {
189
+ db.foo.where('id').equals(1).modify(item => ++item.value);
190
+ }
191
+ return yield db.foo.get(1);
192
+ });
193
+ equal(result.value, NUM_UPDATES, `Should have updated id 1 a ${NUM_UPDATES} times`);
194
+ });