From e2bcf9085628e59d110892cbe5c4d656c3205f78 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Thu, 3 Jul 2025 10:59:28 -0400 Subject: [PATCH] Migrate Zotero.Promise#timeout() in db.js --- chrome/content/zotero/xpcom/db.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js index 7dbd7e6813..b76be4a297 100644 --- a/chrome/content/zotero/xpcom/db.js +++ b/chrome/content/zotero/xpcom/db.js @@ -436,7 +436,13 @@ Zotero.DBConnection.prototype.executeTransaction = async function (func, options try { while (this._transactionID) { - await this.waitForTransaction(id).timeout(options.waitTimeout || 30000); + await Promise.race([ + this.waitForTransaction(id), + new Promise((resolve, reject) => setTimeout( + () => reject(new Zotero.DBConnection.TimeoutError()), + options.waitTimeout || 30000 + )) + ]); } startedTransaction = true; this._transactionID = id; @@ -523,7 +529,7 @@ Zotero.DBConnection.prototype.executeTransaction = async function (func, options return result; } catch (e) { - if (e.name == "TimeoutError") { + if (e instanceof Zotero.DBConnection.TimeoutError) { Zotero.debug(`Timed out waiting for transaction ${id}`, 1); } else { @@ -1489,3 +1495,5 @@ Zotero.DBConnection.prototype._debug = function (str, level) { var prefix = this._dbName == 'zotero' ? '' : '[' + this._dbName + '] '; Zotero.debug(prefix + str, level); } + +Zotero.DBConnection.TimeoutError = class extends Error {};