Repository navigation
fix(storage): close the SQLite handle when UnifiedStore.open fails on a corrupt index (#2771 follow-up) - #2788
Merged
Conversation
… a corrupt index #2771 made a corrupt index.db degrade to legacy-only with the advice "delete the file to reset the index" — but open() leaked the handle it had just created (pragma/migrate throws after the Database constructor succeeds, since better-sqlite3 only reads the header on first statement execution). On Windows you cannot delete a file a live process holds open, so the documented recovery path was impossible, and the leaked fd also kept EPERM-failing the engine-proof tmpdir cleanup. - UnifiedStore.open: wrap pragma+migrate in try/catch, db.close(), rethrow - engine-proof corrupt-index test: pin the contract with a portable renameSync(dir) guard — POSIX tolerates open handles (always passes), Windows refuses to move a directory containing an open file
Contributor
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3061-pr.2788.1bc7232This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2788.tgz
npm install -g packageInstall instructions are refreshed on each push. |
Contributor
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.283-master.e7b94a2 # this exact build
npm install -g billion-context@master # always the newest merged build
|
This was referenced Oct 11, 2026
Merged
Closed
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.
Problem
test (windows-latest, 22/24)is red on master and currently blocks the release PR #2767 — one failure:(The other three Windows failures from #2772 were fixed by #2781's first commit; this one landed after that PR was merged, so it never reached master.)
Root cause — a product bug, not test hygiene
UnifiedStore.open(src/storage/store.ts) opens the Database handle, then throws on the first pragma/migrate statement (SqliteError: file is not a database) without closing the handle — better-sqlite3 only reads the header on first statement execution, so the constructor had succeeded. Consequences:Fix
UnifiedStore.open: wrap pragma+migrate intry/catch→db.close()→ rethrow. The shadow's legacy-only degradation ([Bug][storage] corrupt index.db bricks SessionStore construction in shadow/full mode (violates the sidecar never-breaks-legacy policy) #2771) then works with zero live handles.renameSync(dir)must succeed — POSIX always allows it (no-op guard), Windows refuses to move a directory containing an open file.Tests
storage-engine-proofs10/10,tsc --noEmitcleanUnblocks #2767 (release v0.1.193).
prepared by an agent under the local git identity (ranxianglei), human merge required