MCPcopy
hub / github.com/claude-code-best/claude-code / collectStderr

Function collectStderr

src/ssh/createSSHSession.ts:429–450  ·  view source on GitHub ↗
(proc: Subprocess, chunks: string[])

Source from the content-addressed store, hash-verified

427}
428
429function 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}

Callers 3

createSSHSessionFunction · 0.85
reconnectFunction · 0.85
createLocalSSHSessionFunction · 0.85

Calls 2

readMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected