Skip to content

Fails to detect OpenCode usage data on Windows #1

Description

@luziyi

Issue: code-usage fails to detect OpenCode usage data on Windows with "no local data found", even though opencode.db exists at ~/.local/share/opencode/opencode.db and sqlite3 CLI is installed.

Root Cause: The queryDb function in opencode.js collector uses Node.js execFileSync("sqlite3", ...) to query the SQLite database. On Windows, execFileSync has a default maxBuffer of 1 MB (1024 × 1024 bytes). The serialized JSON of the message table exceeded this limit (~1.06 MB for 1,930 messages), causing an ENOBUFS error. The error was silently caught by the empty catch block, returning empty data.

Fix (applied by AI): Increased maxBuffer to 10 MB for all three execFileSync calls in queryDb():
node_modules\code-usage\src\collectors\opencode.js
Changed { encoding: "utf8", timeout: 10000 } → { encoding: "utf8", timeout: 10000, maxBuffer: 10 * 1024 * 1024 } for the sessions, messages, and projects queries. After the fix, code-usage correctly detected 68 sessions.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions