Skip to content

Node hosts: package fails to load (TS entry) and the dashboard never returns after a location release #60

Open

Description

@Yandre97

Both problems below are on the same host: OpenCode v2.3.0 running as a Node service (OpenChamber desktop bundles opencode-server/chunks/*.mjs; the runtime is no longer the Bun-compiled binary). Plugin version 0.21.5.

1. The published package cannot load on a Node host

Installing per the README ("plugins": ["@hueyexe/opencode-ensemble@latest"]) fails at load:

msg="loading plugin" id=@hueyexe/opencode-ensemble@latest
  entrypoint=.../node_modules/@hueyexe/opencode-ensemble/src/index.ts
WARN message="failed to load plugin" cause="Error [ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING]:
  Stripping types is currently unsupported for files under node_modules, for
  '.../node_modules/@hueyexe/opencode-ensemble/src/index.ts'"

package.json has "exports": { ".": "./src/index.ts" } and "module": "src/index.ts". That works on Bun but Node's ESM loader refuses to strip types under node_modules. dist/index.js shipped in the tarball is never used because exports wins.

Cloning the repo and pointing the config at the folder gets further but hits the next Node-only problem — the sources import without file extensions (import ... from "./v2-setup"), which Node ESM does not resolve:

ERR_MODULE_NOT_FOUND: Cannot find module '.../opencode-ensemble/src/v2-setup'
  imported from .../opencode-ensemble/src/index.ts

Working setup I ended up with (no plugin source changes, host-side only):

  1. npm install --legacy-peer-deps --omit=optional in the clone.
  2. esbuild src/index.ts --bundle --platform=node --format=esm --target=node24 --outfile=dist/index.js --external:node:* --external:bun:* --external:@opentui/* --external:solid-js "--banner:js=import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);"
    The banner is needed because something in the bundle calls require("child_process") CJS-style; without it the ESM output dies with Dynamic require of "child_process" is not supported.
  3. A one-file wrapper package whose module/main/exports all point at dist/index.js, referenced from the project config as { "package": "<abs path>" }.

After that the plugin loads and /api/health answers {"ensemble":true,"pid":...}.

A "exports" map that resolves to ./dist/index.js for the default condition (and keeps src for Bun if you want) would make the documented install work on both runtimes. Happy to send that as a PR if it's not already planned.

2. After a successful load, the plugin is torn down once and never comes back

Once running, the dashboard on 127.0.0.1:4747 disappears when the host releases the project/location (switching projects or closing the tab for that directory). The only trace is:

INFO message="watcher stopped" path=".../opencode-ensemble/src" type=directory
INFO message="watcher stopped" path=".../opencode-ensemble/src/index.ts" type=file

No error, no "dashboard stopped" line. After that:

  • 127.0.0.1:4747 has zero listeners, GET /api/health is refused;
  • creating new sessions in the same directory does not reload the plugin — the host keeps treating it as loaded for that location, so there is no further loading plugin log line at all;
  • the panel that consumes /api/state sits on "unreachable" forever, which reads as a plugin crash.

Data is safe: ~/.config/opencode/ensemble.db keeps teams/tasks/messages, and a forced reload restores everything.

Forcing a new plugin id/path in the config (e.g. renaming the wrapper folder) makes the host reload it and the dashboard returns immediately.

What I suspect

The dashboard server lives in the plugin module's scope (startDashboard() from server()), so when the host tears the plugin down the server goes with it. If OpenCode's plugin cache is per-directory and does not re-run server() after a teardown, the plugin stays dead until the config changes. Two things might help on the plugin side:

  • re-check/try to re-bind the dashboard on the next hook invocation (any tool call, session.idle, etc.), instead of only in server();
  • log a line when the dashboard stops, so a dead port is not indistinguishable from "never started".

Environment

  • Windows 11, OpenChamber desktop (Electron), OpenCode server v2.3.0 (Node runtime), Node 24.14 locally
  • @hueyexe/opencode-ensemble@0.21.5
  • Project config: .opencode/opencode.json with { "plugins": [{ "package": "<local build>" }] }

Both sections are reproducible on this host; I can provide the exact config and the built wrapper if useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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