( id: number, dataDir: string, callCount: number, )
| 141 | * always close. Never throws — failures are captured in the report so the |
| 142 | * scenario can assert across the whole fleet. */ |
| 143 | const runOneClient = async ( |
| 144 | id: number, |
| 145 | dataDir: string, |
| 146 | callCount: number, |
| 147 | ): Promise<ClientReport> => { |
| 148 | const transport = new StdioClientTransport({ |
| 149 | command: "bun", |
| 150 | args: ["run", "dev:cli", "mcp", "--scope", testScope], |
| 151 | cwd: repoRoot, |
| 152 | env: { ...process.env, EXECUTOR_DATA_DIR: dataDir }, |
| 153 | stderr: "pipe", |
| 154 | }); |
| 155 | const client = new Client({ name: `stress-client-${id}`, version: "1.0.0" }); |
| 156 | const results: string[] = []; |
| 157 | let errBuf = ""; |
| 158 | transport.stderr?.on("data", (d: Buffer) => { |
| 159 | errBuf += d.toString(); |
| 160 | }); |
| 161 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: capture per-client failure for fleet-wide assertions |
| 162 | try { |
| 163 | await client.connect(transport); |
| 164 | const { tools } = await client.listTools(); |
| 165 | for (let i = 0; i < callCount; i++) { |
| 166 | // A value unique to (client, call) so a misrouted reply is detectable. |
| 167 | const expr = `return ${id} * 1000 + ${i}`; |
| 168 | const r = await client.callTool({ name: "execute", arguments: { code: expr } }); |
| 169 | const text = (r.content as Array<{ type: string; text: string }>)[0]?.text ?? ""; |
| 170 | results.push(text); |
| 171 | } |
| 172 | return { id, ok: true, tools: tools.length, results }; |
| 173 | } catch (error) { |
| 174 | return { |
| 175 | id, |
| 176 | ok: false, |
| 177 | tools: 0, |
| 178 | results, |
| 179 | error: |
| 180 | (error instanceof Error ? error.message : String(error)) + |
| 181 | (errBuf |
| 182 | ? `\n stderr: ${errBuf.trim().split("\n").slice(-6).join("\n ")}` |
| 183 | : ""), |
| 184 | }; |
| 185 | } finally { |
| 186 | await transport.close().catch(() => undefined); |
| 187 | } |
| 188 | }; |
| 189 | |
| 190 | /** `executor mcp` now ensures a DURABLE (detached) daemon and bridges to it, so a |
| 191 | * cold-start scenario leaves that daemon running. Stop it before removing the |
no test coverage detected