fix(indexeddb): patch 5 bugs in PR #678 IndexedDB implementation + add tests#686
Closed
fix(indexeddb): patch 5 bugs in PR #678 IndexedDB implementation + add tests#686
Conversation
- Remove debug console.log and // debugger from IDBTimelineDatabase.judgeIndex - Fix IDBIndex.getAll(hosts-array) bug: iterate per-host with IDBKeyRange.only() - Fix batchSave merge-duration calculation (use tickEnd before start is mutated) - Add onblocked handler in BaseIDBStorage.initDb upgrade path - Make DB_NAME lazy (getDbName()) so chrome.runtime.id is safe at module load - Guard IndexedMigrator.onUpdate to only migrate from versions < 4.x - Fix NaN guard for malformed version strings in IndexedMigrator - Remove leftover debug console.log from OptionLines.tsx - Add 7 tests for IDBTimelineDatabase (batchSave & select) using fake-indexeddb - Add 6 tests for IndexedMigrator version-gated migration logic Co-authored-by: sheepzh <19428473+sheepzh@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Review support for IndexedDB to store tracking data
fix(indexeddb): patch 5 bugs in PR #678 IndexedDB implementation + add tests
Feb 24, 2026
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.
Review and follow-up fixes for the IndexedDB tracking-data storage feature. Five correctness bugs, two leftover debug statements, and missing test coverage addressed.
Bug Fixes
IDBTimelineDatabase.batchSave— two critical bugsIDBIndex.getAll()called with an array (src/database/timeline-database/idb.ts)IDBIndex.getAll(query)accepts a single key orIDBKeyRange, not an array. Passinghosts[]always returned zero results, silently defeating all conflict-detection and merge logic — every tick was unconditionally inserted.Incorrect merged-interval end —
startwas mutated before being used to computeduration:BaseIDBStorage.initDb— missingonblockedhandlerWithout a handler, a blocked DB upgrade (another tab holds the old version open) hangs indefinitely. Now rejects with an actionable error message.
DB_NAMEevaluated at module load timeconst DB_NAME = \tt4b_${chrome.runtime.id}`threw in environments wherechrome.runtimeis not yet initialised. Changed to a lazygetDbName()called only insideinitDb`.IndexedMigrator.onUpdate— migration ran on every updateClassic→IndexedDB migration fired on every extension update regardless of the previous version. Added a
major < 4version guard and aNaNsafety check for malformed version strings.Debug Code Removed
console.log(host, start)+// debuggerinIDBTimelineDatabase.judgeIndexconsole.log('Found non-VNode child …')inOptionLines.tsxTests Added
test/database/timeline-database/idb.test.ts(7 tests) —batchSaveconflict skip, correct merge bounds, cross-host independence, empty-list safety;selectfilters by start/host. Usesfake-indexeddb.test/background/migrator/indexed-migrator.test.ts(6 tests) — migration triggered only formajor < 4, skipped for≥ 4, safe on empty/malformed version strings.Original prompt
This pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.