GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor(server): replace Bun serve with Hono node adapters by thdxr · Pull Request #18335 · anomalyco/opencode

Conversation

@thdxr

@thdxr thdxr commented Mar 20, 2026 •
edited by greptile-apps Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Summary

  • Replaces Bun.serve with Hono's node server adapter (@hono/node-server) and WebSocket adapter (@hono/node-ws) to decouple the HTTP server from the Bun runtime
  • Updates PTY route handling to use Hono-compatible WebSocket upgrade flow
  • Adds structured server info return with a stop() method for clean workspace server shutdown
  • Bundles database migrations into the node build and auto-starts the server on port 1338

Context

This is the server layer portion remaining from the opencode-2-0 branch after extracting SQLite abstraction, portable process, OAuth, node entry point, and other changes into separate PRs (#18308, #18318, #18320, #18324, #18327, #18328).

Confidence Score: 2/5

  • Not safe to merge — PTY WebSocket routes are disabled, WorkspaceServer.Listen() has an async race condition, and server.stop() is dead code in CLI command handlers.
  • Three distinct P1 issues: a silent feature regression (PTY routes commented out), a lifecycle race in WorkspaceServer.Listen(), and unreachable shutdown logic in both serve.ts and web.ts. The port-0 fallback is also behaviorally incorrect. Together these represent meaningful functional regressions introduced by the refactor.
  • packages/opencode/src/server/server.ts and packages/opencode/src/control-plane/workspace-server/server.ts require the most attention.

Important Files Changed

Filename Overview
packages/opencode/src/server/server.ts Core server refactored from Bun.serve to @hono/node-server; PTY routes are commented out (regression), port-0 fallback logic is non-standard, and multi-word variable names violate the style guide.
packages/opencode/src/control-plane/workspace-server/server.ts Migrated to @hono/node-server, but Listen() returns before the server is ready and silently swallows bind errors — unlike the main Server.listen() which properly awaits the "listening" event.
packages/opencode/src/cli/cmd/serve.ts Uses the new Server.listen() API correctly, but server.stop() after await new Promise(() => {}) is dead code that can never be reached.
packages/opencode/src/cli/cmd/web.ts Same dead-code stop() pattern as serve.ts; otherwise cleanly uses the new Listener API.
packages/opencode/src/server/routes/pty.ts Updated to accept upgradeWebSocket from @hono/node-ws and correctly adapts the raw WebSocket to the Pty.Socket interface; the file itself is correct but is never mounted because the route registration in server.ts is commented out.
packages/opencode/src/pty/index.ts No functional changes; subscriber keying logic remains unchanged and works correctly for the Bun-style socket objects it currently handles.
packages/opencode/src/cli/cmd/acp.ts Minor update to use the new Server.listen() return type; logic is unchanged and correct.
packages/opencode/package.json Adds @hono/node-server and @hono/node-ws as runtime dependencies at pinned versions; bun.lock updated accordingly.

Comments Outside Diff (1)

  1. packages/opencode/src/cli/cmd/serve.ts, line 21-22 (link)

    P1 server.stop() is unreachable dead code

    await new Promise(() => {}) creates a promise that never settles, so await server.stop() on the next line can never be reached. The same pattern exists in web.ts at lines 78–79. In practice this means the graceful shutdown path is never exercised — if the process exits (SIGINT, SIGTERM, etc.) the server is killed without going through stop(). Consider removing the dead call or wiring up signal handling:

    await new Promise<void>((resolve) => {
      process.once("SIGINT", resolve)
      process.once("SIGTERM", resolve)
    })
    await server.stop(true)

    The same fix is needed in web.ts.

Last reviewed commit: "chore: extract misc ..."

Greptile also left 4 inline comments on this PR.

Context used:

  • Context used - packages/opencode/AGENTS.md (source)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

greptile-apps[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
thdxr and others added 30 commits March 10, 2026 16:02
@thdxr
refactor: lsp server and core improvements
656fa19
@thdxr
sync
e8ee1e2
@thdxr @greptile-apps
Update packages/opencode/src/npm/index.ts
173128d
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@thdxr @greptile-apps
Update packages/opencode/src/util/which.ts
27f3598
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@thdxr
sync
0e176d3
@thdxr
core: dynamically resolve formatter executable paths at runtime
528daf5
Formatters now determine their executable location when enabled rather than
using hardcoded paths. This ensures formatters work correctly regardless
of how the tool was installed or where executables are located on the system.
@thdxr
core: disable npm bin links to fix package installation in sandboxed …
a9b01be
…environments
@thdxr
core: fix dependency installation failures behind corporate proxies o…
0cdd4e4
…r in CI by disabling Bun cache when network interception is detected
@thdxr
core: enable npm bin links on non-Windows platforms to allow plugin e…
4c57e39
…xecutables to work while keeping them disabled on Windows CI where symlink permissions are restricted
@thdxr
core: fix npm dependency installation on Windows CI by disabling bin …
85c2bb3
…links when symlink permissions are restricted
@thdxr
tui: export sessions using consistent Filesystem API instead of Bun.w…
124a8ab
…rite
@thdxr
sync
b1a15d5
@thdxr
core: fix CLI tools from npm packages not being accessible after inst…
ceb79c7
…all on Windows
@thdxr
sync
0ff8bfe
@thdxr
core: log npm install errors to console for debugging dependency fail…
58cf092
…ures
@thdxr
sync
0faa191
@thdxr
sync
58a4cd0
@thdxr
sync
2678ceb
@thdxr
core: fix custom tool loading to properly resolve module paths
3c2fda4
@thdxr
tui: fix Windows plugin loading by using direct paths instead of file…
b2eae86
… URLs
@Hona @thdxr
fix: work around Bun/Windows UV_FS_O_FILEMAP incompatibility in tar (#…
2f41d89
…16853)
@thdxr
core: add Node.js runtime support
5dc8b4e
Enable running opencode on Node.js by adding platform-specific database adapters and replacing Bun-specific shell execution with cross-platform Process utility.
@thdxr
refactor(server): replace Bun serve with Hono node adapters
406d216
@thdxr
core: bundle database migrations into node build and auto-start serve…
070c167
…r on port 1338
@thdxr
sync
d4e51e0
@thdxr
core: remove shell execution and server URL from plugin API
d67e877
Plugins no longer receive shell access or server URL to prevent unauthorized
execution and limit plugin sandbox surface area.
@thdxr
core: return structured server info with stop method from workspace s…
5f277d1
…erver

- Enables graceful server shutdown for workspace management
- Removes unsupported serverUrl getter that threw errors in plugin context
@thdxr
core: cleaner error output and more flexible custom tool directories
21e72cb
- Removed debug console.log when dependency installation fails so users see clean warning messages instead of raw error dumps
- Fixed database connection cleanup to prevent resource leaks between sessions
- Added support for loading custom tools from both .opencode/tool (singular) and .opencode/tools (plural) directories, matching common naming conventions
@thdxr
sync
4d81e2d
@thdxr
core: enable running in non-Bun environments by using standard Node.j…
a28648f
…s APIs for OAuth servers and retry logic
opencode-agent Bot added a commit that referenced this pull request Apr 1, 2026
@opencode-agent
Apply PR #18335: refactor(server): replace Bun serve with Hono node a…
f9c4113
…dapters
opencode-agent Bot added a commit that referenced this pull request Apr 1, 2026
@opencode-agent
Apply PR #18335: refactor(server): replace Bun serve with Hono node a…
cb85312
…dapters
opencode-agent Bot added a commit that referenced this pull request Apr 1, 2026
@opencode-agent
Apply PR #18335: refactor(server): replace Bun serve with Hono node a…
012b57f
…dapters
@Hona
fix(build-node): preserve Bun linker for node-pty install (#20364)
529a4d5
opencode-agent Bot added a commit that referenced this pull request Apr 1, 2026
@opencode-agent
Apply PR #18335: refactor(server): replace Bun serve with Hono node a…
de9db1f
…dapters
opencode-agent Bot added a commit that referenced this pull request Apr 2, 2026
@opencode-agent
Apply PR #18335: refactor(server): replace Bun serve with Hono node a…
1b5a898
…dapters
opencode-agent Bot added a commit that referenced this pull request Apr 2, 2026
@opencode-agent
Apply PR #18335: refactor(server): replace Bun serve with Hono node a…
23236af
…dapters
opencode-agent Bot added a commit that referenced this pull request Apr 2, 2026
@opencode-agent
Apply PR #18335: refactor(server): replace Bun serve with Hono node a…
1920a52
…dapters
@opencode-agent

opencode-agent Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

⚠️ Blocking Beta Release

This PR cannot be merged into the beta branch due to: Merge conflicts with dev branch

Please resolve this issue to include this PR in the next beta release.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

opencode-agent Bot added a commit that referenced this pull request Apr 2, 2026
@opencode-agent
Apply PR #18335: refactor(server): replace Bun serve with Hono node a…
da41f13
…dapters
opencode-agent Bot added a commit that referenced this pull request Apr 2, 2026
@opencode-agent
Apply PR #18335: refactor(server): replace Bun serve with Hono node a…
a554744
…dapters
opencode-agent Bot added a commit that referenced this pull request Apr 2, 2026
@opencode-agent
Apply PR #18335: refactor(server): replace Bun serve with Hono node a…
cde66b0
…dapters
opencode-agent Bot added a commit that referenced this pull request Apr 2, 2026
@opencode-agent
Apply PR #18335: refactor(server): replace Bun serve with Hono node a…
201a285
…dapters
opencode-agent Bot added a commit that referenced this pull request Apr 2, 2026
@opencode-agent
Apply PR #18335: refactor(server): replace Bun serve with Hono node a…
88fa2d4
…dapters
opencode-agent Bot added a commit that referenced this pull request Apr 2, 2026
@opencode-agent
Apply PR #18335: refactor(server): replace Bun serve with Hono node a…
07f30cd
…dapters
opencode-agent Bot added a commit that referenced this pull request Apr 2, 2026
@opencode-agent
Apply PR #18335: refactor(server): replace Bun serve with Hono node a…
39d67c0
…dapters
opencode-agent Bot added a commit that referenced this pull request Apr 2, 2026
@opencode-agent
Apply PR #18335: refactor(server): replace Bun serve with Hono node a…
37f99ac
…dapters
@opencode-agent

opencode-agent Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

⚠️ Blocking Beta Release

This PR cannot be merged into the beta branch due to: Merge conflicts with dev branch

Please resolve this issue to include this PR in the next beta release.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sjqwert

sjqwert commented Apr 5, 2026

Copy link
Copy Markdown

⚠️ Blocking Beta Release

This PR cannot be merged into the beta branch due to: Merge failed

Please resolve this issue to include this PR in the next beta release.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

1 similar comment
@sjqwert

sjqwert commented Apr 5, 2026

Copy link
Copy Markdown

⚠️ Blocking Beta Release

This PR cannot be merged into the beta branch due to: Merge failed

Please resolve this issue to include this PR in the next beta release.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Brendonovich and others added 3 commits April 6, 2026 17:00
@Brendonovich
Merge branch 'dev' into refactor/hono-server
0d28d22
@thdxr
Merge branch 'dev' into refactor/hono-server
8c7560e
@adamdotdevin
fix: e2e-local script
45220b4
This was referenced Apr 6, 2026
chore: sync upstream/dev (Hono migration, LSP fix, OpenTUI 0.1.97) #21248
Closed
chore: sync upstream/dev (Hono migration, LSP fix, OpenTUI 0.1.97) Cor-Incorporated/opencode#133
Merged
@BYK BYK mentioned this pull request Apr 9, 2026
fix(server): harden embedded web UI serving #19867
Closed
4 of 6 tasks
@achin90 achin90 mentioned this pull request Apr 10, 2026
DispatchTUI prtest achin90/Dispatch#3
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adamdotdevin adamdotdevin Awaiting requested review from adamdotdevin
1 more reviewer
@greptile-apps greptile-apps[bot] greptile-apps[bot] left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

beta Vouched

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@thdxr @sjqwert @Brendonovich @Hona @adamdotdevin
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.