From e8055dfdf2fb1baf3b959acb5d2011a5c6790839 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 21 Aug 2026 16:06:49 -0400 Subject: [PATCH] Open the database only once when callers arrive concurrently _getConnectionAsync() checked for an existing connection and then awaited several filesystem operations before assigning one, so callers arriving in that window each opened their own. Only the last was kept, and the rest stayed open and unreachable, holding a mozStorage thread apiece until shutdown. --- chrome/content/zotero/xpcom/db.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js index 09abc03303..3cc033ea85 100644 --- a/chrome/content/zotero/xpcom/db.js +++ b/chrome/content/zotero/xpcom/db.js @@ -1548,6 +1548,18 @@ Zotero.DBConnection.prototype._getConnectionAsync = async function () { throw new Error("Database permanently closed; not re-opening"); } + // Opening is asynchronous, so callers arriving while it's under way share the same attempt + if (!this._openPromise) { + this._openPromise = this._openConnectionAsync() + .finally(() => { + this._openPromise = null; + }); + } + return this._openPromise; +}; + + +Zotero.DBConnection.prototype._openConnectionAsync = async function () { this._debug("Asynchronously opening database '" + this._dbName + "'"); Zotero.debug(this._dbPath);