Skip to content

OpenCode/Cursor silently empty on Node 22.x < 22.13 (node:sqlite gated behind --experimental-sqlite) #250

Closed

Description

@chatzinikolakisk

Bug

codeburn status shows zero calls and $0.00 for OpenCode (and Cursor) on Node 22.11.0, even with a healthy ~/.local/share/opencode/opencode.db (140 root sessions, 2k+ assistant messages with token data). All other providers (Claude Code, Codex, etc.) work correctly. The failure is silent — no warning printed in normal status/report/today output.

Root cause

dist/cli.js calls requireForSqlite("node:sqlite") to load the built-in module. The node:sqlite module landed in Node 22.5 behind the --experimental-sqlite flag and only became available without a flag starting around Node 22.13 (and stable later). On Node 22.5–22.12 (no flag), the require throws ERR_UNKNOWN_BUILTIN_MODULE: No such built-in module: node:sqlite.

Codeburn catches this and sets loadError, but discoverSessions() in the OpenCode/Cursor providers just returns [] on !isSqliteAvailable() — no surfaced warning. End user sees an empty provider with no clue why.

Reproduction

  • Node 22.11.0 (or any 22.x prior to ~22.13 without --experimental-sqlite)
  • codeburn 0.9.6 (npx codeburn or brew install getagentseal/codeburn/codeburn)
  • Active OpenCode usage with messages in ~/.local/share/opencode/opencode.db
$ node --version
v22.11.0
$ npx codeburn status --provider opencode
  Today  \$0.00  0 calls    Month  \$0.00  0 calls
$ node -e "require('node:sqlite')"
Error [ERR_UNKNOWN_BUILTIN_MODULE]: No such built-in module: node:sqlite

After upgrading to Node 22.22.2:

$ node --version
v22.22.2
$ npx codeburn status --provider opencode
  Today  \$10.39  114 calls    Month  \$10.39  114 calls

Why this is hard to spot

  • README still says `better-sqlite3` is installed automatically as an optional dependency, but the published 0.9.6 `package.json` has no `optionalDependencies`. Users searching for `better-sqlite3` issues hit a dead end.
  • `engines` field is `"node": ">=22"`, so 22.0–22.12 appear supported but silently break SQLite providers.
  • Closed issue SQLite providers silently fail: eval("require") is undefined in ESM context #98 documents an earlier related silent-fail; the current 0.9.6 silent-fail mode is different (built-in module gate) but indistinguishable to a normal user.

Suggested fixes (any one would resolve)

  1. Loud warning when SQLite-backed providers are configured but driver is unavailable. The current loadError message exists but isn't surfaced unless a session parser is actually invoked. Print it during discoverSessions() if any DB files are found on disk but the driver can't load.
  2. Bump engines requirement to whatever Node version makes node:sqlite available without a flag (≈22.13), or document this clearly in README under Requirements.
  3. Fall back to better-sqlite3 when node:sqlite is unavailable, and actually declare it in optionalDependencies (matching the README).
  4. Detect the specific ERR_UNKNOWN_BUILTIN_MODULE case and emit a targeted message: "Your Node version (X) doesn't expose node:sqlite without --experimental-sqlite. Upgrade to Node 22.13+ or pass that flag."

Environment

  • codeburn 0.9.6
  • Node 22.11.0 (broken) → Node 22.22.2 (working)
  • macOS arm64
  • OpenCode 1.14.39

Activity

  1. ozymandiashh commented on May 7, 2026

    @ozymandiashh
    Collaborator

    Thanks for the precise report and root-cause writeup. I opened #256 to address this.

    The fix does two things:

    1. CodeBurn now has a tiny runtime launcher that checks for Node >=22.13.0 before loading the main CLI bundle. That means Node 22.5-22.12 users should now get an actionable upgrade message instead of silently losing SQLite-backed providers when node:sqlite is unavailable without --experimental-sqlite.
    2. Cursor, Goose, and OpenCode discovery now checks whether their SQLite data exists first. If data exists but the SQLite driver cannot load, CodeBurn emits a clear stderr diagnostic instead of returning an empty provider with no clue.

    I also updated the stale README/package metadata: the package no longer documents better-sqlite3, and the engine requirement is now >=22.13.0 to match the unflagged node:sqlite requirement.

    Validation on the PR:

    • npx tsc --noEmit
    • npm run build (verified dist/cli.js is only the runtime guard + dynamic import)
    • npx vitest run — 40 files / 539 tests passing
    • external review pass with Opus 4.7 and Gemini 3.1 Pro Preview

    If you can retest with the same Node 22.11/OpenCode setup once the PR lands or a test package is available, the expected behavior should be a direct Node upgrade diagnostic rather than 0 calls / $0.00.

  2. added a commit that references this issue on May 8, 2026
    b45c6f5
  3. added a commit that references this issue on May 11, 2026
    02f4635
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions