Fix Zotero silently disappearing as a citation source - #1120
Open
juliasilge wants to merge 3 commits into
Open
Conversation
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
juliasilge
marked this pull request as ready for review
September 9, 2026 20:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1101
Zotero could disappear as a citation source in the visual editor, without any error message. This affected the local library, and in one case, newly added items. Four separate bugs caused this, all of which are addressed here:
Quarto > Zotero > Library, the data directory, or the API key pushed the new config one time only. On failure, the extension discarded the result. The LSP then kept the old settings for the rest of the session, with no warning. This now uses the same retry path as the initial sync.getCollectionsandgetActiveCollectionSpecsat the same time. Both requests copy the local Zotero database to the same cache path. A failed open in one request could delete the copy that the other request still needed. As a result, both requests failed withunable to open database file. Access to the cached copy is now one request at a time, per data directory.node-sqlite3-wasmcannot open a WAL-mode database. We now clear the WAL flag in the file header of the throwaway copy before we open it.Changes I decided NOT to make here
These are remaining problems, but I think too risky to try to address now to fix the 1.136.0 regression:
vscode-languageclientlibrary itself. ItsLanguageClient.start()method saves its internal start promise and never clears it after aStartFailedstate. Our retry logic cannot recover from this specific failure for that reason. A correct fix needs a newLanguageClientinstance. That change touches shared LSP startup code for every LSP feature, not only Zotero. Let's leave this alone for now as it is a bigger and more risky change than the rest of this PR.onInitializedhandler. An earlier registration can shrink this race, or maybe remove it, at the source. This also touches shared LSP startup code so let's leave it for now. The retry from fix 1 already covers the common case.-waljournal file. Zotero writes new and changed items to a-walfile first. Zotero moves this data into the mainzotero.sqlitefile only at a checkpoint. Our fix makes the main file open again, but an item added or edited in the Zotero desktop app still does not appear in the citation picker until Zotero checkpoints on its own. A correct fix needs either thesqlite3command-line tool to force a checkpoint, or a different SQLite library that supports WAL mode natively. Both options are bigger changes than this PR should take on; see the separate issue Local Zotero library: new or edited items do not appear until Zotero checkpoints its WAL file #1119.Manual validation
I tested this against a real local Zotero 10 library:
unable to open database fileerror appears in the Quarto output channel.Quarto > Zotero > Librarybetweennoneandlocalwhile the extension was running. Each change syncs the config correctly.