Skip to content

fix(plugin): prevent compiled binary hang by removing lazy dynamic import#1794

Merged
thdxr merged 1 commit intoanomalyco:devfrom
monotykamary:fix/binary-hang-dynamic-import
Aug 11, 2025
Merged

fix(plugin): prevent compiled binary hang by removing lazy dynamic import#1794
thdxr merged 1 commit intoanomalyco:devfrom
monotykamary:fix/binary-hang-dynamic-import

Conversation

@monotykamary
Copy link
Copy Markdown
Contributor

@monotykamary monotykamary commented Aug 11, 2025

Summary

  • Fix binary hang in compiled builds by reverting lazy dynamic import in plugin client to direct Server import/call Can no longer open opencode v0.4.3 #1792.
  • Restores v0.4.2 startup behavior; dev mode unaffected.

Context

  • Regression introduced in v0.4.3 where packages/opencode/src/plugin/index.ts switched to await import('../server/server') inside fetch callback.
  • Bun compile caused startup deadlock before logs; bun dev worked.

Changes

  • plugin/index.ts: direct import { Server } from '../server/server' and Server.app().fetch.

Test plan

  • Build snapshot: OPENCODE_VERSION=0.0.0-dev OPENCODE_SNAPSHOT=true OPENCODE_DRY=true ./packages/opencode/script/publish.ts
  • Run compiled binary: ./packages/opencode/dist/opencode-<os>-<arch>/bin/opencode run -p "ping" --print-logs --log-level DEBUG
  • Verify no hang; TUI also launches.

🤖 Generated with opencode

… binary hang

Lazy import in plugin client fetch caused startup deadlock in compiled builds
(Bun compile) while dev mode worked. Revert to direct import and direct
Server.app() fetch to restore v0.4.2 behavior.

Refs: v0.4.2→v0.4.3 regression observed when running compiled binary.

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>
@monotykamary
Copy link
Copy Markdown
Contributor Author

@thdxr a quick patch to at least get opencode running until we figure out a better way to do prevent the circular import here

@thdxr thdxr merged commit 1c83ef7 into anomalyco:dev Aug 11, 2025
1 check passed
sahilchouksey pushed a commit to sahilchouksey/opencode that referenced this pull request Aug 11, 2025
xywsxp pushed a commit to xywsxp/opencode that referenced this pull request Apr 24, 2026
…port (anomalyco#1794)

Co-authored-by: opencode <noreply@opencode.ai>
Rwanbt pushed a commit to Rwanbt/opencode that referenced this pull request May 5, 2026
…port (anomalyco#1794)

Co-authored-by: opencode <noreply@opencode.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants