mirror of
https://github.com/readest/readest.git
synced 2026-11-30 03:13:39 +00:00
* fix(koplugin): collect sync workers before KOReader exits
Exiting KOReader from inside a book quits about a second after the
close-time pushes fork their workers. UIManager:quit() empties the task
queue, so the polls that would collect those workers never run and the
workers keep going after KOReader is gone. The reporter's Kindle often
segfaulted at exit when that happened.
The sync client now keeps the pid of every forked worker (sync RPCs,
book and cover downloads) and wraps UIManager.quit: running workers get
up to 5 s to finish, then the rest are killed and reaped before the
original quit runs.
Verified:
- New syncclient specs: a worker that finishes in the grace period is
waited for, a stuck one is killed after 50 x 100 ms, and quit doesn't
wait with no workers. Without the change the first two fail
("Expected 3, passed 0" and "Expected 50, passed 0").
- pnpm test:lua (510 passed), pnpm lint:lua.
- Kindle Voyage, firmware 5.13.6, KOReader v2026.07.2-300 (no Turbo),
exiting from inside the book with auto sync on. origin/main: 2 of 5
exits left workers running after KOReader was gone (reparented to
init). This change: 4 of 4 exits logged "waiting for sync workers
before exit", then killed and reaped the 3 workers still stuck in TLS;
none outlived KOReader. No segfault in either build on this device, so
the crash itself was not reproduced.
- Not verified: a worker finishing within the grace period on a device
(every push on the test network timed out in TLS), and Android.
Fixes #6685. Reported by tramch on GitHub.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(koplugin): deliver finished worker results at exit and keep partial covers out of the cache
Review follow-up for #6685:
- The exit wait reaped a worker that finished inside the grace period
but never ran its poll, so a token refresh that completed there lost
its rotated refresh token. Sync RPC workers now register their poll
with trackWorker, and the exit wait runs it for every worker that has
finished. Workers that callbacks start then share the same 5 s budget.
- A cover worker killed at exit left a partial <hash>.png that the cover
cache treats as complete. The worker now writes <hash>.png.part and
renames it only after a 200; failures remove the .part.
Verified: two new specs fail without this change
("delivers the response of a worker that finishes while KOReader quits":
expected 1 reply, got 0; "keeps a cover under a temporary name until it
is complete": the file was at dst mid-transfer). pnpm test:lua (512
passed), pnpm lint:lua. Not run on the device: the Kindle could not
reach the Readest API at the time (curl timed out after 10 s).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(koplugin): give each cover download worker its own temporary file
Review follow-up for #6685. The manual Download Cover action bypasses
the automatic cover queue, so two workers can download the same cover
at once. With one shared <hash>.png.part, one worker could rename it
while the other was still writing, and the second then reported a
failure. Each worker now writes <hash>.png.<pid>.part.
Verified: "keeps a cover under a temporary name until it is complete"
fails without the change (no h1.png.123.part mid-transfer: expected
"file", got nil). pnpm test:lua (512 passed), pnpm lint:lua.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| bim_patch.lua | ||
| cloud_covers.lua | ||
| cloud_icons.lua | ||
| coverprovider.lua | ||
| downloadqueue.lua | ||
| exts.lua | ||
| group_covers.lua | ||
| libraryitem.lua | ||
| librarypaint.lua | ||
| librarystore.lua | ||
| libraryviewmenu.lua | ||
| librarywidget.lua | ||
| list_strip.lua | ||
| localscanner.lua | ||
| localsend_firewall.lua | ||
| localsend_helper.lua | ||
| readingstatus.lua | ||
| statussync.lua | ||
| syncbooks.lua | ||