{"record":{"id":"7f6cb64443c39fc7","repo":"can1357/oh-my-pi","slug":"dap-adapter-parent-adapter-name-cannot-accept-c","errorCode":null,"errorMessage":"DAP adapter ${parent.adapter.name} cannot accept child session connections","messagePattern":"DAP adapter (.+?) cannot accept child session connections","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/dap/session.ts","lineNumber":1198,"sourceCode":"\t\tfor (const session of this.#sessions.values()) {\n\t\t\tif (\n\t\t\t\tsession.status === \"terminated\" ||\n\t\t\t\tnow - session.lastUsedAt > IDLE_TIMEOUT_MS ||\n\t\t\t\t!session.client.isAlive()\n\t\t\t) {\n\t\t\t\tthis.#disposeSession(session);\n\t\t\t}\n\t\t}\n\t}\n\n\tasync #startChildSession(\n\t\tparent: DapSession,\n\t\trequest: \"launch\" | \"attach\",\n\t\tconfiguration: Record<string, unknown>,\n\t\ttimeoutMs: number = 30_000,\n\t): Promise<void> {\n\t\tif (parent.adapter.connectMode !== \"tcp\" || parent.port === undefined) {\n\t\t\tthrow new Error(`DAP adapter ${parent.adapter.name} cannot accept child session connections`);\n\t\t}\n\t\tconst cwd = path.resolve(parent.cwd, typeof configuration.cwd === \"string\" ? configuration.cwd : \".\");\n\t\tconst client = await DapClient.connect({\n\t\t\tadapter: parent.adapter,\n\t\t\tcwd,\n\t\t\thost: \"127.0.0.1\",\n\t\t\tport: parent.port,\n\t\t});\n\t\tconst child = this.#registerSession(\n\t\t\tclient,\n\t\t\tparent.adapter,\n\t\t\tcwd,\n\t\t\ttypeof configuration.program === \"string\" ? configuration.program : undefined,\n\t\t\tparent.id,\n\t\t);\n\t\ttry {\n\t\t\tchild.capabilities = await client.initialize(\n\t\t\t\tthis.#buildInitializeArguments(parent.adapter),","sourceCodeStart":1180,"sourceCodeEnd":1216,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/dap/session.ts#L1180-L1216","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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"],"exampleFix":"// before\n// parent adapter: connectMode 'pipe' (stdio)\nawait manager.startChildSession(parent, 'launch', { program });\n// after\n// launch parent with TCP server mode first\nconst parent = await manager.launch({ adapter: tcpServerAdapter, configuration });\nawait manager.startChildSession(parent, 'attach', { port: parent.port });","handlingStrategy":"validation","validationCode":"if (parent.adapter.connectMode !== 'tcp' || typeof parent.port !== 'number') {\n  throw new Error('child sessions require a TCP parent adapter with a known port');\n}","typeGuard":"function supportsChildSessions(parent: DapSession): boolean {\n  return parent.adapter.connectMode === 'tcp' && typeof parent.port === 'number';\n}","tryCatchPattern":"try {\n  await manager.startChildSession(parent, 'attach', configuration);\n} catch (err) {\n  if (String((err as Error).message).includes('cannot accept child session')) {\n    // relaunch parent in TCP server mode or start a separate root session\n    parent = await manager.launch({ ...config, adapter: tcpAdapter });\n    await manager.startChildSession(parent, 'attach', configuration);\n  } else { throw err; }\n}","preventionTips":["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"],"tags":["dap","tcp","configuration","multi-session"],"backgroundTag":"adapter-transport-unsupported","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}