diff --git a/ts/data/dataInit.ts b/ts/data/dataInit.ts index 319c08ed7..541aa43c3 100644 --- a/ts/data/dataInit.ts +++ b/ts/data/dataInit.ts @@ -263,9 +263,13 @@ function removeJob(id: number) { } function makeJob(fnName: string) { - if (_shuttingDown && fnName !== 'close') { + if (_shuttingDown && fnName !== 'close' && fnName !== 'removeDB') { throw new Error(`Rejecting SQL channel job (${fnName}); application is shutting down`); } + if (!_shuttingDown && fnName === 'close') { + window?.log?.debug(`SQL channel job close() called, marking as shutting down`); + _shuttingDown = true; + } _jobCounter += 1; const id = _jobCounter; diff --git a/ts/node/sqlInstance.ts b/ts/node/sqlInstance.ts index 5491c937d..850fc2577 100644 --- a/ts/node/sqlInstance.ts +++ b/ts/node/sqlInstance.ts @@ -37,7 +37,7 @@ export function closeDbInstance() { } const dbRef = globalInstance; globalInstance = null; - // SQLLite documentation suggests that we run `PRAGMA optimize` right before + // SQlite documentation suggests that we run `PRAGMA optimize` right before // closing the database connection. dbRef.pragma('optimize'); dbRef.close();