fix(browser): keep the IndexedDB model cache cleared after a reset - #43
Merged
Merged
Conversation
A load that started before clearModelCache() could reopen the deleted database through its old cache and write the model back, where a new cache read it. A cache now stays empty once its database is deleted or a reset has run since it was created, and only caches created after the reset open the database again. The IndexedDB tests now run against fake-indexeddb, so they check that a reset really deletes stored models. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Comments Outside DiffThese findings could not be posted inline.
|
This branch was successfully deployed
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.
Follow-up to #42, fixing Greptile's P1 there.
clearModelCache()deletes the IndexedDB model cache, but a load that started before the reset still held the old cache. After #42 closed its connection onversionchange, the old cache reopened on its next write. That recreated the deleted database and wrote the model back, where a new cache read it, even after a reload.An IndexedDB cache now stays empty once its database is deleted, or once a reset has run since it was created. Its reads miss and its writes are dropped. Only caches created after the reset open the database again. Another tab's reset retires this tab's cache the same way, so that tab stops caching the model until it reloads.
The IndexedDB tests now use
fake-indexeddb(Apache-2.0, dev only) instead of a hand-rolled mock. They cover Greptile's P2 as well: a reset must delete stored models, and a clear that targets the wrong database now fails. The three write-back tests fail on main.I checked the same scenarios in headless Chrome's real IndexedDB, loading the built
cache.jsover plain http on this machine's Tailscale address. On main, a write after a reset was readable from a new cache in all three cases: a cache that had opened before the reset, one first used after it, and a delete from another tab. With this change, none were readable. Stored models are gone after a reset, and a cache created afterward reads and writes normally.I also ran the remover on WASM from this branch's build over the same plain-http origin, so it used IndexedDB:
Not tested: WebGPU, iOS, and the Cache API path, which this change does not touch. Root lint, typecheck, test and build pass.
Created with Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code