can1357/oh-my-pi · error · Error
DAP adapter ${parent.adapter.name} cannot accept child sessi
Error message
DAP adapter ${parent.adapter.name} cannot accept child session connections What it means
Child debug sessions can only connect to a parent adapter that listens on TCP and exposes a port, because multiple clients attach via the network socket. If the parent adapter uses stdio (pipe) transport or has no recorded port, spawning a child client is impossible and the manager refuses up front.
Source
Thrown at packages/coding-agent/src/dap/session.ts:1198
for (const session of this.#sessions.values()) {
if (
session.status === "terminated" ||
now - session.lastUsedAt > IDLE_TIMEOUT_MS ||
!session.client.isAlive()
) {
this.#disposeSession(session);
}
}
}
async #startChildSession(
parent: DapSession,
request: "launch" | "attach",
configuration: Record<string, unknown>,
timeoutMs: number = 30_000,
): Promise<void> {
if (parent.adapter.connectMode !== "tcp" || parent.port === undefined) {
throw new Error(`DAP adapter ${parent.adapter.name} cannot accept child session connections`);
}
const cwd = path.resolve(parent.cwd, typeof configuration.cwd === "string" ? configuration.cwd : ".");
const client = await DapClient.connect({
adapter: parent.adapter,
cwd,
host: "127.0.0.1",
port: parent.port,
});
const child = this.#registerSession(
client,
parent.adapter,
cwd,
typeof configuration.program === "string" ? configuration.program : undefined,
parent.id,
);
try {
child.capabilities = await client.initialize(
this.#buildInitializeArguments(parent.adapter),View on GitHub (pinned to 9690622007)
Solutions
- Launch the parent adapter in TCP/server mode so it accepts multiple client connections and exposes a port
- Ensure the adapter's listen output is parsed so parent.port is set (match 'listening at HOST:PORT')
- Use an adapter/adapter-config that supports multi-session (e.g. debugpy multi-session, js-debug server mode)
- If the adapter is stdio-only, launch a separate top-level session per debuggee instead of a child session
Example fix
// before
// parent adapter: connectMode 'pipe' (stdio)
await manager.startChildSession(parent, 'launch', { program });
// after
// launch parent with TCP server mode first
const parent = await manager.launch({ adapter: tcpServerAdapter, configuration });
await manager.startChildSession(parent, 'attach', { port: parent.port }); Defensive patterns
Strategy: validation
Validate before calling
if (parent.adapter.connectMode !== 'tcp' || typeof parent.port !== 'number') {
throw new Error('child sessions require a TCP parent adapter with a known port');
} Type guard
function supportsChildSessions(parent: DapSession): boolean {
return parent.adapter.connectMode === 'tcp' && typeof parent.port === 'number';
} Try / catch
try {
await manager.startChildSession(parent, 'attach', configuration);
} catch (err) {
if (String((err as Error).message).includes('cannot accept child session')) {
// relaunch parent in TCP server mode or start a separate root session
parent = await manager.launch({ ...config, adapter: tcpAdapter });
await manager.startChildSession(parent, 'attach', configuration);
} else { throw err; }
} Prevention
- Choose adapters/configs with TCP server (multi-session) support when child sessions are needed
- Assert connectMode === 'tcp' and port !== undefined before any child-session API call
- Ensure the adapter's listen output is parsed so port is recorded on the parent session
- For stdio-only adapters, launch independent root sessions per debuggee instead
When it happens
Trigger: Calling startChildSession (launch/attach of a child) while parent.adapter.connectMode is 'pipe' (stdio); parent launched over TCP but parent.port is undefined (port never recorded, e.g. port announced but not parsed, or socket-mode launch); child attach attempted on an adapter that only supports one stdio client.
Common situations: Multi-process debugging configured against a stdio adapter that only supports single-session; parent session launched without a known port (adapter assigns ephemeral port not propagated); trying to fork child sessions on adapters lacking multi-session support (needs --server mode).
Related errors
- Adapter process exited before TCP port ${host}:${port} was r
- TCP port ${host}:${port} was not ready after ${timeoutMs}ms
- No debugger adapter available. Installed adapters: ${getConf
- No model configured
- Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/7f6cb64443c39fc7.
Report an issue: GitHub.