can1357/oh-my-pi · error · Error
Adapter process exited before socket was ready
Error message
Adapter process exited before socket was ready
What it means
When launching a socket-based (stdio pipe or TCP) DAP adapter, the client waits for a readiness check (e.g. socket/port availability) before use. If the adapter process exits (non-null exitCode) before that check succeeds, this error is thrown because the process will never become ready. It distinguishes 'not ready yet' from 'adapter died at startup'.
Solutions
- Run the adapter command manually with the same args/cwd to see its startup error output
- Fix the adapter path, runtime, and launch configuration (program, cwd, env) in the resolved adapter config
- Check the adapter's stderr/stdout logs for the crash reason; capture them at launch
- Verify the adapter binary is executable and compatible with the platform (e.g. correct arch)
Example fix
// before
adapter: { command: 'node', args: ['--inspect', 'dbg.js'] } // crashes on old node
// after
adapter: { command: 'node', args: ['--loader', './dap-loader.mjs', 'dbg.js'] } // verify with: node --loader ./dap-loader.mjs dbg.js Defensive patterns
Strategy: validation
Validate before calling
const proc = Bun.spawn([adapter.command, ...adapter.args], { cwd, stderr: 'pipe' });
// surface early failure before waiting for readiness
proc.exited.then(code => { if (code !== 0) console.error(await new Response(proc.stderr).text()); }); Try / catch
try {
await DapClient.connect({ adapter, cwd, timeoutMs: 10_000 });
} catch (err) {
if (String((err as Error).message).includes('exited before')) {
console.error('adapter startup failed; check adapter path/args and stderr logs');
}
throw err;
} Prevention
- Validate the adapter command exists and is executable before launch ($which)
- Smoke-test the adapter command line manually with the exact args/cwd from config
- Capture and log adapter stdout/stderr at launch so startup crashes are diagnosable
- Pin adapter/runtime versions to known-working combinations
When it happens
Trigger: The adapter executable crashes immediately after launch (bad interpreter, missing module, invalid config passed via launch args); the launch command errors out before opening its socket; the adapter exits during the startup window while waitFor readiness is polling.
Common situations: Wrong adapter path or runtime in debug config (e.g. node version without required flags); a Python debugpy entrypoint typo'd so the process dies; adapter killed by missing environment variables or unresolvable cwd; port configured but adapter fails to bind and exits.
Related errors
- Adapter process exited before TCP port
- DAP adapter exited before write completed
- Socket not ready after
- DAP adapter is not running
- No active stack frame. Run stack_trace first or supply…
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/1e12f6a3f4876faf.
Report an issue: GitHub.
Appendix: source
Thrown at packages/coding-agent/src/dap/client.ts:779
try {
return (await fs.stat(socketPath)).isSocket();
} catch (error) {
if (isEnoent(error)) return false;
throw error;
}
}
/** Poll a condition until it returns true, or timeout/process exit. */
async function waitForCondition(
check: () => boolean | Promise<boolean>,
timeoutMs: number,
proc: { exitCode: number | null },
): Promise<void> {
const deadline = Date.now() + timeoutMs;
while (Date.now() < deadline) {
if (await check()) return;
if (proc.exitCode !== null) {
throw new Error("Adapter process exited before socket was ready");
}
await Bun.sleep(50);
}
throw new Error(`Socket not ready after ${timeoutMs}ms`);
}
/** Connect once to a TCP DAP server. */
async function connectTcpSocket(host: string, port: number, onClose?: () => void): Promise<SocketTransport> {
const { promise, resolve, reject } = Promise.withResolvers<SocketTransport>();
let streamController: ReadableStreamDefaultController<Uint8Array>;
let opened = false;
const readable = new ReadableStream<Uint8Array>({
start(controller) {
streamController = controller;
},
});
void Bun.connect({View on GitHub (pinned to 9690622007)