(proc: Subprocess, chunks: string[])
| 427 | } |
| 428 | |
| 429 | function collectStderr(proc: Subprocess, chunks: string[]): void { |
| 430 | const stderr = proc.stderr |
| 431 | if (!stderr) return |
| 432 | |
| 433 | const reader = (stderr as ReadableStream<Uint8Array>).getReader() |
| 434 | const decoder = new TextDecoder() |
| 435 | |
| 436 | void (async () => { |
| 437 | try { |
| 438 | while (true) { |
| 439 | const { done, value } = await reader.read() |
| 440 | if (done) break |
| 441 | chunks.push(decoder.decode(value, { stream: true })) |
| 442 | if (chunks.length > STDERR_TAIL_LINES * 2) { |
| 443 | chunks.splice(0, chunks.length - STDERR_TAIL_LINES) |
| 444 | } |
| 445 | } |
| 446 | } catch { |
| 447 | // stderr closed — expected on process exit |
| 448 | } |
| 449 | })() |
| 450 | } |
no test coverage detected