Skip to content

Configure timeout: OpenCode's embedded JS runtime doesn't deliver stdin.write() to child process #1

@RobinVivant

Description

@RobinVivant

Bug Report

Apologies in advance - I'm filing this with AI assistance as I don't have the bandwidth to debug this further myself.

Environment

  • OpenCode: v1.3.10 (30e609e0)
  • Plugin: @cortexkit/aft-opencode@0.9.1
  • Binary: aft v0.9.1 (from versioned cache)
  • OS: Debian (Linux 6.1), 2 vCPU Intel Xeon, 3.7GB RAM

Problem

The configure request times out after 30s on every startup. The aft binary spawns successfully but never receives the NDJSON command on stdin. After 3 restart attempts, the plugin gives up entirely.

[aft-plugin] Spawning binary: aft (cwd: /home/user)
[aft-plugin] [aft] started, pid XXXX
[aft-plugin] Request "configure" (id=1) timed out after 30000ms — restarting bridge
[aft-plugin] Max restarts (3) reached, giving up.

Root cause (upstream)

This is a bug in OpenCode's embedded JS runtime (Go-based), not in the AFT plugin or binary. OpenCode's implementation of child_process.spawn() has a buffering issue where stdin.write() data is accepted but never flushed to the child process.

Evidence:

  • echo '{"id":"1","command":"configure",...}' | aft → responds instantly
  • bun test-bridge.mjs (same spawn + stdin.write code) → responds instantly
  • node test-bridge.mjs → responds instantly
  • Inside OpenCode plugin runtime → binary sits in unix_stream_data_wait forever

I've filed the upstream issue at https://github.com/sst/opencode/issues (stdin.write buffering bug).

Possible workaround

Since the root cause is in OpenCode's stdio pipe handling, the AFT plugin could potentially work around it by using an alternative IPC mechanism instead of stdin/stdout pipes:

  • Unix domain socket
  • Temp file polling
  • Named pipe (FIFO)
  • TCP localhost

This would bypass OpenCode's broken child_process.spawn() stdin implementation entirely.

Impact

The plugin is completely non-functional - all AFT tools fail because the bridge can never complete the initial configure handshake. The tools register successfully with OpenCode but every actual invocation triggers the configure flow which always times out.

Metadata

Metadata

Assignees

No one assigned

    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