10.0.6: Early local API request can leave item loading permanently pending

I investigated intermittent stalled item loading/PDF opening on Windows 11 and found a reproducible native startup race, independently of functional plugins. Posting here per CONTRIBUTING.md rather than opening an unsolicited GitHub issue.

Environment: Zotero 10.0.6, Windows 11 x64, Ryzen 7 5800H, approximately 24 GB RAM, Radeon integrated graphics and RTX 3060 Laptop. Hardware WebRender/D3D11 are available. The local API is enabled and local clients can issue requests while Zotero starts. The isolated comparison disables all functional plugins, retaining only an existing diagnostic bridge. Its endpoint was not yet registered when the early native API failure occurred.

Reproduction and observed state


  1. Start Zotero with an existing library containing item creators and the local API enabled.

  2. While the HTTP server starts, issue a read-only request such as GET http://127.0.0.1:23119/api/users/0/items?limit=1&format=keys.

  3. If it reaches item loading before the Creators cache initializes, the request returns HTTP 500 with Creator 25 not found from Creators.get → Items._loadCreators.

  4. Wait for startup to finish. Creators.get(25) now succeeds, and SQLite contains that creator and all references are valid. Nevertheless subsequent item loading/PDF opening can remain pending: the library load deferred was never settled or cleared.

In the recorded native comparison the sequence is:

GET /api/users/0/items
Waiting for items to load for library 1
Loading primaryData ...
Loading creators ...
Error: Creator 25 not found
Creators.get ... creators.js:74
Items._loadCreators ... items.js:457
HTTP 500
[later] SELECT * FROM creators
[later] Running initialization callbacks

The early diagnostic-bridge POST got 404; that plugin starts later. User-Agent alone does not identify the initiating consumer, so I am not attributing the first request to a particular MCP or client.

Read-only follow-up queries found creator 25 present, five referencing itemCreators rows and zero dangling creator references. Calling Creators.get(25) then worked. Reader.open still exceeded a 20-second observation deadline. No data deletion or database repair was performed.

Native source path


  • zotero.js, 10.0.6: Server.init() occurs before Items.init() and Creators.init() (around line 752).

  • server_localAPI.js: the data endpoint reaches library.waitForDataLoad('item') without a global initialization/dependency barrier.

  • dataObjects.js: loadAll() creates a library load deferred, awaits each stage, and only settles it on success. A failing stage has no rejection/reset path.

  • library.js:434–445 then reuses that pending deferred instead of retrying. _loadCreators also marks an item's creators loaded before retrieving creator data, leaving partial state after an exception.

The endpoint and loadAll logic were checked against the current default branch too, not only the installed package.

Controlled comparisons and mitigation boundary


























Recorded fresh-start conditionResult
All functional plugins disabled, only diagnostic bridge retainedEarly native item request fails before creator initialization; PDF open exceeds 20 seconds
Same plugin condition, intentional read-only early GETHTTP 500, same creator error, PDF open exceeds 20 seconds again
Successful native startup where item loading follows creator initializationSame PDF at 210% completes 32 scroll steps; six SELECT-1 transactions take 1–5 ms; no reader error
Original functional plugins restored, successful item initializationSame 32-step workload completes, but background delays vary substantially between runs

I attempted configuration-level API gating before startup and restored the original setting after initialization. However, later early-request checks returned 200 or 500 rather than demonstrating a consistent 403 gate. Therefore those labelled test runs must not be represented as a proven durable API-gating fix. The concrete failure/success distinction is the observed ordering of item loading versus creator initialization. An endpoint-level readiness barrier is a proposed code repair, not a patch installed on this machine.

Full-plugin runs also show separate background latency: one limited SELECT-1 probe timed out at a test-specific 5-second threshold, and another transaction completed after approximately 15 seconds. There is no claim that fixing the startup race will resolve every rendering delay or the separate column-refresh failure.

For a read-only external reproducer, run this before starting Zotero with its local API already enabled. It makes one request once the port accepts connections, prints only the status, and does not modify library data:

import time, urllib.request, urllib.error
op = urllib.request.build_opener(urllib.request.ProxyHandler({}))
deadline = time.monotonic() + 60
while time.monotonic() < deadline:
try:
with op.open('http://127.0.0.1:23119/api/users/0/items?limit=1&format=keys', timeout=15) as r:
r.read()
print(r.status)
break
except urllib.error.HTTPError as e:
print(e.code)
break
except urllib.error.URLError:
time.sleep(0.1)

Reproduction is timing-dependent. A development test can deliberately hold Creators initialization while allowing this endpoint to load an existing item with a creator, then complete initialization and verify that a subsequent library-data wait settles/retries rather than hanging.

Suggested repair areas

Gate local API data access on complete initialization (or return retryable 503 while dependencies are not ready). Independently, loading failure should reject/reset the shared library-loading promise and invalidate partial item loaded flags so later calls can retry. Moving just one initializer earlier would not address failure-state cleanup or other not-yet-ready API dependencies.

An offline replay of the exact selected shipped library/loadAll/loadCreators/Creators functions, with synthetic in-memory rows containing creator 25 from the outset, reproduces: first load rejects, Creators.init later succeeds, subsequent load and shared deferred remain pending. No real app/DB is used by that replay. The reproducer and sanitized excerpts are available for follow-up; raw logs contain private paths/authentication headers and are intentionally not uploaded.

This confirms a startup/data-load bug. It does not establish that every earlier frozen or blurry PDF session had this identical cause.

Sign In or Register to comment.