Restore the novel script's lost module-scope constants (#74) #75

Merged
sulthan merged 1 commits from fix/74-novel-missing-constants into main 2026-08-10 18:12:04 +07:00
Owner

This was generated by AI during triage.

Fixes #74.

novel-bookmark.user.js was split out of manga-bookmark.user.js and lost four module-scope constants. Every use of them is behind a try/catch or a fire-and-forget promise, so the ReferenceErrors were swallowed rather than reported.

constant used at effect while missing
LATEST_CHECK_THROTTLE_MS :722 backgroundRefreshLatest() throws before computing due — no background latest-check ever runs for novels (the symptom in #74)
LATEST_CHECK_BATCH :724 same throw
CACHE_KEY :215, :224 loadCache() always returns [], saveCache() silently no-ops — the local cache never persists
LASTCHECKED_KEY :232, :241 last-checked map never persists, so the throttle would not hold even once the first two are defined

#74 named only the two throttle constants. The two cache keys are the same lost lines with the same root cause, so they are restored here too — fixing only the pair the issue named would leave backgroundRefreshLatest() re-fetching every series on every navigation, because saveLastChecked() would still be a no-op.

Values and comments copied verbatim from manga-bookmark.user.js:37-43; throttle 4h, batch 1.

Verification

  • node --check userscript/novel-bookmark.user.js — clean.
  • node --test userscript/test/logic.test.js userscript/test/novel-logic.test.js — 47/47 pass.
  • New test every SCREAMING_CASE constant the script uses is declared in it scans both scripts (comments and string literals stripped first, so prose and SVG path data do not trip it). Confirmed it fails — 1 failing test — when LATEST_CHECK_BATCH is deleted again, and passes when restored.

A behavioural test cannot reach this: the storage helpers and the background refresh are exactly the layers the harness does not cover (see the testing-the-userscript skill), and the errors are swallowed anyway. A static guard is the only instrument that sees this bug class.

On-device confirmation that the ember now lights for novels is still outstanding — that needs Violentmonkey against a live novelfull/lightnovelworld page.

> *This was generated by AI during triage.* Fixes #74. `novel-bookmark.user.js` was split out of `manga-bookmark.user.js` and lost four module-scope constants. Every use of them is behind a `try/catch` or a fire-and-forget promise, so the `ReferenceError`s were swallowed rather than reported. | constant | used at | effect while missing | | --- | --- | --- | | `LATEST_CHECK_THROTTLE_MS` | `:722` | `backgroundRefreshLatest()` throws before computing `due` — no background latest-check ever runs for novels (the symptom in #74) | | `LATEST_CHECK_BATCH` | `:724` | same throw | | `CACHE_KEY` | `:215`, `:224` | `loadCache()` always returns `[]`, `saveCache()` silently no-ops — the local cache never persists | | `LASTCHECKED_KEY` | `:232`, `:241` | last-checked map never persists, so the throttle would not hold even once the first two are defined | #74 named only the two throttle constants. The two cache keys are the same lost lines with the same root cause, so they are restored here too — fixing only the pair the issue named would leave `backgroundRefreshLatest()` re-fetching every series on every navigation, because `saveLastChecked()` would still be a no-op. Values and comments copied verbatim from `manga-bookmark.user.js:37-43`; throttle 4h, batch 1. ## Verification - `node --check userscript/novel-bookmark.user.js` — clean. - `node --test userscript/test/logic.test.js userscript/test/novel-logic.test.js` — 47/47 pass. - New test `every SCREAMING_CASE constant the script uses is declared in it` scans both scripts (comments and string literals stripped first, so prose and SVG path data do not trip it). Confirmed it fails — 1 failing test — when `LATEST_CHECK_BATCH` is deleted again, and passes when restored. A behavioural test cannot reach this: the storage helpers and the background refresh are exactly the layers the harness does not cover (see the `testing-the-userscript` skill), and the errors are swallowed anyway. A static guard is the only instrument that sees this bug class. On-device confirmation that the ember now lights for novels is still outstanding — that needs Violentmonkey against a live novelfull/lightnovelworld page.
sulthan added 1 commit 2026-08-10 18:10:15 +07:00
novel-bookmark.user.js was split out of manga-bookmark.user.js and lost
four constants: CACHE_KEY, LASTCHECKED_KEY, LATEST_CHECK_THROTTLE_MS and
LATEST_CHECK_BATCH. Every use sits behind a try/catch or a
fire-and-forget promise, so the ReferenceErrors were swallowed:
backgroundRefreshLatest() threw before its first fetch, and the local
cache silently read empty and never persisted.

The issue named the two throttle constants; the cache keys are the same
lost lines and are fixed here too.

Add a static guard over both scripts, since no behavioural test can see
a swallowed ReferenceError.
sulthan merged commit b22ae82897 into main 2026-08-10 18:12:04 +07:00
Sign in to join this conversation.