MCPcopy
hub / github.com/coder/mux / processStream

Function processStream

src/node/services/coderService.ts:200–226  ·  view source on GitHub ↗
(stream: NodeJS.ReadableStream | null, isStderr: boolean)

Source from the content-addressed store, hash-verified

198 };
199
200 const processStream = (stream: NodeJS.ReadableStream | null, isStderr: boolean) => {
201 if (!stream) {
202 markDone();
203 return;
204 }
205 let buffer = "";
206 stream.on("data", (chunk: Buffer) => {
207 buffer += chunk.toString();
208 const parts = buffer.split("\n");
209 buffer = parts.pop() ?? "";
210 for (const line of parts) {
211 const trimmed = line.trim();
212 if (trimmed) {
213 pushLine(trimmed);
214 if (isStderr) stderrLines.push(trimmed);
215 }
216 }
217 });
218 stream.on("end", () => {
219 if (buffer.trim()) {
220 pushLine(buffer.trim());
221 if (isStderr) stderrLines.push(buffer.trim());
222 }
223 markDone();
224 });
225 stream.on("error", markDone);
226 };
227
228 processStream(child.stdout, false);
229 processStream(child.stderr, true);

Callers 1

streamCoderCommandFunction · 0.85

Calls 4

markDoneFunction · 0.85
pushLineFunction · 0.85
onMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected