Skip to content

Commit

Permalink
SQLite: fix time measurement
Browse files Browse the repository at this point in the history
confusion between callbacks and promises :-/
  • Loading branch information
wmertens committed Jul 19, 2023
1 parent 64ca803 commit c196108
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/DB/SQLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,20 @@ class SQLiteImpl extends EventEmitter {
now = performance.now()
return _sqlite[method](...(args || []), cb)
})
.finally(() => {
duration = performance.now() - now
this._sema.release()
})
.catch(cb)
}
: () => {
fnResult = _sqlite[method](...(args || []), cb)
}
let busyRetry = RETRY_COUNT
// We need to consume `this` from sqlite3 callback
// eslint-disable-next-line unicorn/no-this-assignment, @typescript-eslint/no-this-alias -- we need it
const self = this
cb = function (err, out) {
if (shouldDebug) {
duration = performance.now() - now
self._sema.release()
}
if (err) {
if (isBusyError(err) && busyRetry--) {
dbgQ(`${name} busy, retrying`)
Expand Down

0 comments on commit c196108

Please sign in to comment.