| 93 | util.itUnix('should accept the "timeout" option', function () { |
| 94 | this.slow(5000); |
| 95 | const testTimeout = (timeout) => { |
| 96 | const db = new Database(util.current(), { timeout }); |
| 97 | try { |
| 98 | const start = Date.now(); |
| 99 | expect(() => db.exec('BEGIN EXCLUSIVE')).to.throw(Database.SqliteError).with.property('code', 'SQLITE_BUSY'); |
| 100 | const end = Date.now(); |
| 101 | // GHA is slow: a 500ms timeout can take 1685ms to fail. |
| 102 | expect(end - start).to.be.within(timeout - 1, timeout * 3 + 300); |
| 103 | } finally { |
| 104 | db.close(); |
| 105 | } |
| 106 | }; |
| 107 | const blocker = this.db = new Database(util.next(), { timeout: 0x7fffffff }); |
| 108 | blocker.exec('BEGIN EXCLUSIVE'); |
| 109 | testTimeout(0); |