Skip to content

Plugin fails to load in OpenCode Desktop (Electron): bun:sqlite not supported #15

@CKGrafico

Description

@CKGrafico

Problem

The plugin fails to load in OpenCode Desktop (Electron/Node.js runtime) with this error:

error=Only URLs with a scheme in: file, data, node, and electron are supported by the default ESM loader. Received protocol 'bun:' failed to load plugin

The root cause is line in dist/index.js:

import { Database } from "bun:sqlite";

The bundle has // @bun at the top, meaning it was compiled with Bun's bundler which inlines bun: protocol imports. These are Bun-specific and are rejected by Node.js/Electron's ESM loader.

Why the CLI works but Desktop doesn't

  • OpenCode CLI (opencode terminal command) ships as a native Bun binary (opencode-windows-x64/bin/opencode.exe). It runs on Bun, so bun:sqlite works fine.
  • OpenCode Desktop is an Electron app. Electron uses Node.js as its JS runtime, which does not support bun: protocol URLs.

Impact

  • Every startup of OpenCode Desktop triggers repeated plugin load failures
  • The retry loop on each worktree causes the app to freeze on startup
  • Ensemble tools (team_create, team_spawn, etc.) are completely non-functional in Desktop

Affected versions

Checked all published versions (0.1.00.14.1) — all have bun:sqlite in the bundle.

Fix

Rebuild the bundle targeting Node.js/Electron instead of Bun. Replace bun:sqlite with a Node-compatible alternative:

  • better-sqlite3 drop-in replacement, same synchronous API (db.exec(), db.query().get(), etc.)
  • node:sqlite built-in since Node 22, but API differs slightly and it's still experimental

better-sqlite3 is the safest drop-in with no API changes needed in src/db.ts.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions