novel-bookmark.user.js: background latest-check throws ReferenceError, never runs #74

Closed
opened 2026-08-10 18:00:49 +07:00 by sulthan · 1 comment
Owner

Found during live verification of #63 (Playwright agent, 2026-08-10) — unrelated to covers, not touched there.

Symptom: backgroundRefreshLatest() on every novel site (novelfull.com, lightnovelworld.net) throws a ReferenceError and exits before any fetch. Background latest-chapter tracking silently never runs for the novel library; the rejection is unhandled.

Cause: userscript/novel-bookmark.user.js uses two constants it never defines:

  • LATEST_CHECK_THROTTLE_MS (line 722)
  • LATEST_CHECK_BATCH (line 724)

The manga script defines both (userscript/manga-bookmark.user.js:42-43). The novel script's constants block (around line 32) omits them — looks like a lost line when the novel script was split from the manga one.

Call sites (fire-and-forget, no catch): lines 1218 and 1334.

Impact: backgroundRefreshLatest throws before due is computed, so no series page is ever fetched in the background — "new chapter" ember for novels relies entirely on on-page capture (maybeCaptureLatestOnSeriesPage) and on direct navigation to the series page.

Fix: define both constants in the novel script's constants block, matching the manga values (throttle 4h, batch 1). One-line addition.

Verified live: ReferenceError: LATEST_CHECK_THROTTLE_MS is not defined observed on novelfull.com and lightnovelworld.net.

Found during live verification of #63 (Playwright agent, 2026-08-10) — unrelated to covers, not touched there. **Symptom:** `backgroundRefreshLatest()` on every novel site (novelfull.com, lightnovelworld.net) throws a `ReferenceError` and exits before any fetch. Background latest-chapter tracking silently never runs for the novel library; the rejection is unhandled. **Cause:** `userscript/novel-bookmark.user.js` uses two constants it never defines: - `LATEST_CHECK_THROTTLE_MS` (line 722) - `LATEST_CHECK_BATCH` (line 724) The manga script defines both (`userscript/manga-bookmark.user.js:42-43`). The novel script's constants block (around line 32) omits them — looks like a lost line when the novel script was split from the manga one. **Call sites (fire-and-forget, no catch):** lines 1218 and 1334. **Impact:** `backgroundRefreshLatest` throws before `due` is computed, so no series page is ever fetched in the background — "new chapter" ember for novels relies entirely on on-page capture (`maybeCaptureLatestOnSeriesPage`) and on direct navigation to the series page. **Fix:** define both constants in the novel script's constants block, matching the manga values (throttle 4h, batch 1). One-line addition. Verified live: `ReferenceError: LATEST_CHECK_THROTTLE_MS is not defined` observed on novelfull.com and lightnovelworld.net.
sulthan added the needs-triage label 2026-08-10 18:00:49 +07:00
sulthan added bugready-for-human and removed needs-triage labels 2026-08-10 18:10:26 +07:00
Author
Owner

This was generated by AI during triage.

Triage

Category: bug. State: ready-for-human (fix is up as #75, needs a human merge + on-device confirmation).

Confirmed, and wider than reported. The novel script is missing four module-scope constants, not two — the same lost block from the manga/novel split:

  • LATEST_CHECK_THROTTLE_MS, LATEST_CHECK_BATCH — as reported; backgroundRefreshLatest() throws before its first fetch.
  • CACHE_KEY (:215, :224), LASTCHECKED_KEY (:232, :241) — also undeclared. These reads sit inside try/catch, so loadCache() just returns [] forever and saveCache()/saveLastChecked() silently no-op. The local cache has never persisted on novel sites.

The last one matters for the fix: defining only the two throttle constants would leave saveLastChecked() a no-op, so the 4h throttle would never hold and every navigation would re-fetch a series. All four are restored together in #75.

Verification: node --check clean; node --test userscript/test/logic.test.js userscript/test/novel-logic.test.js 47/47. #75 adds a static guard over both scripts that asserts every SCREAMING_CASE identifier used is also declared — confirmed to fail when a constant is deleted again. No behavioural test can see this: the errors are swallowed, and storage + background refresh are outside the harness.

Remaining human step: merge #75, then confirm on-device (Violentmonkey, live novelfull / lightnovelworld) that the new-chapter ember lights for novels without visiting the series page.

> *This was generated by AI during triage.* ## Triage **Category:** bug. **State:** ready-for-human (fix is up as #75, needs a human merge + on-device confirmation). **Confirmed, and wider than reported.** The novel script is missing four module-scope constants, not two — the same lost block from the manga/novel split: - `LATEST_CHECK_THROTTLE_MS`, `LATEST_CHECK_BATCH` — as reported; `backgroundRefreshLatest()` throws before its first fetch. - `CACHE_KEY` (`:215`, `:224`), `LASTCHECKED_KEY` (`:232`, `:241`) — also undeclared. These reads sit inside `try/catch`, so `loadCache()` just returns `[]` forever and `saveCache()`/`saveLastChecked()` silently no-op. The local cache has never persisted on novel sites. The last one matters for the fix: defining only the two throttle constants would leave `saveLastChecked()` a no-op, so the 4h throttle would never hold and every navigation would re-fetch a series. All four are restored together in #75. **Verification:** `node --check` clean; `node --test userscript/test/logic.test.js userscript/test/novel-logic.test.js` 47/47. #75 adds a static guard over both scripts that asserts every `SCREAMING_CASE` identifier used is also declared — confirmed to fail when a constant is deleted again. No behavioural test can see this: the errors are swallowed, and storage + background refresh are outside the harness. Remaining human step: merge #75, then confirm on-device (Violentmonkey, live novelfull / lightnovelworld) that the new-chapter ember lights for novels without visiting the series page.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sulthan/mangaBookmark#74