Skip to content

Commit

Permalink
deps: updated to 4.0.0 of @matrixai/async-locks and switched to usi…
Browse files Browse the repository at this point in the history
…ng `ContextTimedInput`
  • Loading branch information
CMCDragonkai committed Jun 25, 2023
1 parent c80ada6 commit 7717f9f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 71 deletions.
68 changes: 9 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
"node-forge": "^1.3.1",
"node-gyp": "9.0.0",
"prettier": "^2.6.2",
"shx": "^0.3.4",
"semver": "^7.3.7",
"shx": "^0.3.4",
"systeminformation": "^5.12.1",
"ts-jest": "^28.0.5",
"ts-node": "^10.9.1",
Expand Down
22 changes: 11 additions & 11 deletions tests/DBTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1035,9 +1035,9 @@ describe(DBTransaction.name, () => {
);
await db.withTransactionF(async (tran2) => {
await tran2.lock(['foo', 'read']);
await expect(tran2.lock(['bar', 'write', 0])).rejects.toThrow(
locksErrors.ErrorAsyncLocksTimeout,
);
await expect(
tran2.lock(['bar', 'write', { timer: 0 }]),
).rejects.toThrow(locksErrors.ErrorAsyncLocksTimeout);
expect(tran1.locks.size).toBe(2);
expect(tran1.locks.has('foo')).toBe(true);
expect(tran1.locks.get('foo')!.type).toBe('read');
Expand Down Expand Up @@ -1097,9 +1097,9 @@ describe(DBTransaction.name, () => {
// This is a noop, because `tran1` owns `key1` and `key2`
await tran2.unlock('key1', 'key2');
// This fails because `key1` is still locked by `tran1`
await expect(tran2.lock(['key1', 'write', 0])).rejects.toThrow(
locksErrors.ErrorAsyncLocksTimeout,
);
await expect(
tran2.lock(['key1', 'write', { timer: 0 }]),
).rejects.toThrow(locksErrors.ErrorAsyncLocksTimeout);
await tran1.unlock('key1');
expect(tran1.locks.size).toBe(1);
// This succeeds because `key1` is now unlocked
Expand All @@ -1109,9 +1109,9 @@ describe(DBTransaction.name, () => {
await tran1.unlock('key1');
expect(tran2.locks.has('key1')).toBe(true);
expect(tran1.locks.has('key1')).toBe(false);
await expect(tran1.lock(['key1', 'write', 0])).rejects.toThrow(
locksErrors.ErrorAsyncLocksTimeout,
);
await expect(
tran1.lock(['key1', 'write', { timer: 0 }]),
).rejects.toThrow(locksErrors.ErrorAsyncLocksTimeout);
});
await tran1.lock('key1');
expect(tran1.locks.has('key1')).toBe(true);
Expand All @@ -1126,8 +1126,8 @@ describe(DBTransaction.name, () => {
// Currently a deadlock can happen, and the only way to avoid is to use timeouts
// In the future, we want to have `DBTransaction` detect deadlocks
// and automatically give us `ErrorDBTransactionDeadlock` exception
const p1 = tran1.lock(['bar', 'write', 50]);
const p2 = tran2.lock(['foo', 'write', 50]);
const p1 = tran1.lock(['bar', 'write', { timer: 50 }]);
const p2 = tran2.lock(['foo', 'write', { timer: 50 }]);
const results = await Promise.allSettled([p1, p2]);
expect(
results.every(
Expand Down

0 comments on commit 7717f9f

Please sign in to comment.