[WEB-2706] fix: Fix issue with SQLite transactions (#5934)

* - Fix transaction within transaction issue
- Close DB handles on reload
- Fix GET_ISSUES tracking

* Cleanup stray code

* Fix lint error

* Possible fix for NoModificationAllowedError
This commit is contained in:
Satish Gandham 2024-11-04 16:54:13 +05:30 committed by GitHub
parent 20b2a70939
commit a1bfde6af9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 26 additions and 9 deletions

View file

@ -37,8 +37,18 @@ export class Storage {
constructor() {
this.db = null;
if (typeof window !== "undefined") {
window.addEventListener("beforeunload", this.closeDBConnection);
}
}
closeDBConnection = async () => {
if (this.db) {
await this.db.close();
}
};
reset = () => {
if (this.db) {
this.db.close();
@ -293,7 +303,10 @@ export class Storage {
let issuesRaw: any[] = [];
let count: any[];
try {
[issuesRaw, count] = await Promise.all([runQuery(query), runQuery(countQuery)]);
[issuesRaw, count] = await startSpan(
{ name: "GET_ISSUES" },
async () => await Promise.all([runQuery(query), runQuery(countQuery)])
);
} catch (e) {
logError(e);
const issueService = new IssueService();