From 7fe1162405d3a0b85ac038dff8ac26f260ccdf75 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 1 Sep 2026 22:54:15 -0400 Subject: [PATCH] Don't clear the saved session if startup fails Zotero.Session.save() runs from a quit-application-granted observer registered before the database checks, but session.json is only read after them, so a startup error -- an incompatible database from a newer version, say -- meant that quitting overwrote the file with an empty state and all open tabs were lost. https://forums.zotero.org/discussion/133542/ (cherry picked from commit 9e28eb0d39d86a2df19e4f952c8533b748b1aa09) --- chrome/content/zotero/xpcom/session.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/chrome/content/zotero/xpcom/session.js b/chrome/content/zotero/xpcom/session.js index f96875e1d2..3e47a06d5d 100644 --- a/chrome/content/zotero/xpcom/session.js +++ b/chrome/content/zotero/xpcom/session.js @@ -30,6 +30,7 @@ Zotero.Session = new function () { let _state = { windows: [] }; + let _initialized = false; Zotero.defineProperty(this, 'state', { get: () => { @@ -48,6 +49,7 @@ Zotero.Session = new function () { Zotero.logError(e); } } + _initialized = true; }; this.setLastClosedZoteroPaneState = function (state) { @@ -59,6 +61,11 @@ Zotero.Session = new function () { }, DEBOUNCED_SAVING_DELAY); this.save = async function () { + // Don't overwrite the saved session if startup failed before the session was loaded + if (!_initialized) { + return; + } + try { // Saving is triggered in `zotero.js` when a quit event is received, // though if it was triggered by closing a window, ZoteroPane might