Fix WAL-mode Cursor state.vscdb auth (unable to open database file) - #14
Merged
Conversation
node-sqlite3-wasm cannot open WAL databases, which is why 0.3.1 threw "unable to open database file" against Cursor's live state DB. Copy to a temp file, strip the WAL flag on the copy only, and decode ItemTable BLOBs as UTF-8. Co-authored-by: Maruan Biasi El Achkar <codykoinabox@maruanbiasi.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.
Problem
0.3.1 switched from sql.js (load file into memory) to
node-sqlite3-wasm(open on disk) sostate.vscdbfiles over 2 GiB still authenticate.Cursor keeps
state.vscdbin WAL mode. That WASM build cannot open WAL databases at all. Querying it throws:That hits every install, not just huge DBs. Confirmed locally: native sqlite3 WAL file, header bytes 18/19 = 2, in-place open fails; copy + strip WAL flag on the copy succeeds.
Fix (0.3.2)
COPYFILE_FICLONEwhen the FS supports it), set format-version bytes to rollback on the copy only, then query.ItemTableBLOBs as UTF-8. VS Code stores those values as blobs; treating them as strings only would fail after the WAL open started working.Tests
unable to open database file;readAuthFromStateDbstill returns the token and does not mutate the source filesqlite3WAL fixture with sidecars (skipped ifsqlite3is missing)npx tsc --noEmit,npx vitest run(28 tests),npm run compile,vsce packageall green locally.Release
Version bumped to 0.3.2. After merge, tag
v0.3.2sorelease.ymlpublishes to Open VSX and creates the GitHub release.