Skip to content

Fix WAL-mode Cursor state.vscdb auth (unable to open database file) - #14

Merged
cursor[bot] merged 1 commit into
mainfrom
cursor/fix-state-db-cantopen-881a
Aug 29, 2026
Merged

Fix WAL-mode Cursor state.vscdb auth (unable to open database file)#14
cursor[bot] merged 1 commit into
mainfrom
cursor/fix-state-db-cantopen-881a

Conversation

@CodyKoInABox

Copy link
Copy Markdown
Owner

Problem

0.3.1 switched from sql.js (load file into memory) to node-sqlite3-wasm (open on disk) so state.vscdb files over 2 GiB still authenticate.

Cursor keeps state.vscdb in WAL mode. That WASM build cannot open WAL databases at all. Querying it throws:

Could not read Cursor session from local DB: unable to open database file

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)

  • If the SQLite header says WAL (or in-place open fails with CANTOPEN/BUSY), copy to a temp file (COPYFILE_FICLONE when the FS supports it), set format-version bytes to rollback on the copy only, then query.
  • Never writes Cursor’s live database.
  • Non-WAL files still open in place (no multi-GiB copy).
  • Decode ItemTable BLOBs as UTF-8. VS Code stores those values as blobs; treating them as strings only would fail after the WAL open started working.

Tests

  • Existing ItemTable + >2 GiB sparse-file tests
  • WAL header stamp: raw WASM open throws unable to open database file; readAuthFromStateDb still returns the token and does not mutate the source file
  • BLOB UTF-8 decode
  • Native sqlite3 WAL fixture with sidecars (skipped if sqlite3 is missing)

npx tsc --noEmit, npx vitest run (28 tests), npm run compile, vsce package all green locally.

Release

Version bumped to 0.3.2. After merge, tag v0.3.2 so release.yml publishes to Open VSX and creates the GitHub release.

Open in Web Open in Cursor 

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>
@cursor
cursor Bot merged commit 5a086d6 into main Aug 29, 2026
4 checks passed
@cursor
cursor Bot deleted the cursor/fix-state-db-cantopen-881a branch August 29, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants