Fix critical reliability bugs across extension#1
Open
ashrielbrian wants to merge 4 commits intomasterfrom
Open
Fix critical reliability bugs across extension#1ashrielbrian wants to merge 4 commits intomasterfrom
ashrielbrian wants to merge 4 commits intomasterfrom
Conversation
…ection, error handling - Unify popup/background DB storage path (idb://casper) so search actually returns results - Add getOrCreatePage() so pages are inserted before embeddings (fixes orphaned rows) - Consolidate process_page into single lock acquisition (fixes race conditions) - Add try/catch to all background message handlers (fixes hung responses) - Replace forEach(async...) with for...of in filter transactions (fixes silent failures) - Parameterize all SQL queries (fixes SQL injection in storeEmbeddings, intervals, countRows) - Add null safety and fix React dependency arrays in Search/Settings/SearchResults - Wrap extractDomain in try/catch, fix zip for mismatched arrays - Cache tokenizer singleton, add getDB error recovery, clean up dead code Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add [casper]-prefixed console logging to all background.ts message handlers so processing decisions and errors are visible in the service worker console - Content script now checks background response and warns on failure - Fix HNSW index CREATE missing IF NOT EXISTS (caused initSchema to fail on second invocation, breaking all subsequent DB operations) - Add initSchema idempotency regression test - Switch popup to PGliteWorker.create() (documented async API) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Chunk IDs were tracking the last node instead of the first, causing search result links to scroll to the wrong location. Also cleaned up empty fragment anchors in SearchResults. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…iss confirmation - nukeDb: wrap in transaction, remove redundant cascade-covered deletes - onSettingsSave: move setHasChanged after await, add try/catch - deleteDb: auto-dismiss "Database cleared!" message after 3s - Add nukeDb test verifying page/embedding/cache cleared, filters preserved - Fix pre-existing crypto polyfill issue for Node 18 test environment Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Commit 1: Core reliability fixes
idb://casper.dbwhile background usedidb://casper— two separate databases, so search always returned empty. Both now shareDB_STORAGEconstant.getOrCreatePage()so pages are inserted before embeddings, eliminating orphaned rows withpage_id = null.process_pagehandler into a single lock acquisition (was 3 separate lock/unlock cycles).sendResponsenow called after the lock releases.sendResponseis always called, even on errors.saveFilterSitesandremoveFilterSitesusedforEach(async ...)which doesn't await — transactions committed with zero queries. Replaced withfor...of.countRows.extractDomainwrapped in try/catch,ziphandles mismatched array lengths.getDB()error recovery, cached tokenizer singleton, content script error handling, worker cleanup on unmount.getDBName, unusedPGliteWorkerimport, no-opsaveModelType, console.logs.Commit 2: Logging, HNSW index fix, PGliteWorker.create()
[casper]-prefixed logging to allbackground.tsmessage handlers — processing decisions (skip/process/done) and errors are now visible in the service worker console. Previously there was zero logging, making it impossible to diagnose "embeddings not generated" reports.CREATE INDEX ON embedding USING hnsw ...was missingIF NOT EXISTS, causinginitSchemato fail on second invocation and breaking all subsequent DB operations in that process lifetime.PGliteWorker.create()— documented async API with proper TypeScript extension types.Commit 3: Fix search result anchor navigation
curr_idis set once from the first node and reset correctly when a new chunk begins.SearchResults.tsxno longer appends a bare#whenchunk_tag_idis null/empty.Commit 4: Fix Settings page reliability
nukeDb: wrapped in transaction, removed redundant deletes already handled byON DELETE CASCADE.onSettingsSave: movedsetHasChanged(false)after the asyncupdateSites()call so the Save button stays enabled if the save fails. Added try/catch with error logging.tests/setup.tsto polyfillglobalThis.cryptofor Node 18 —crypto.randomUUID()ininitSchemawas causing all tests to fail under thetsxloader.nukeDbtest: verifies page/embedding/cache are cleared while filter sites are preserved.Test plan
pnpm test— all 9 tests pass (including nukeDb and idempotency tests)pnpm build— production build succeedsbuild/chrome-mv3-prod)[casper] Processing <url>/[casper] Done processing <url>[casper] Skipping <url> (already processed)🤖 Generated with Claude Code