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);