MCPcopy Index your code
hub / github.com/github/copilot-sdk / connectToChildProcessViaStdio

Method connectToChildProcessViaStdio

nodejs/src/client.ts:2412–2442  ·  view source on GitHub ↗

* Connect to child via stdio pipes

()

Source from the content-addressed store, hash-verified

2410 * Connect to child via stdio pipes
2411 */
2412 private async connectToChildProcessViaStdio(): Promise<void> {
2413 if (!this.cliProcess) {
2414 throw new Error("CLI process not started");
2415 }
2416
2417 // Keep stdin pipe errors inside the normal JSON-RPC teardown path.
2418 // Preserve the failure reason via the gated debug log rather than discarding it.
2419 this.cliProcess.stdin?.on("error", (err) => {
2420 if (this.forceStopping) {
2421 return;
2422 }
2423 this.state = "error";
2424 const reason = err instanceof Error ? (err.stack ?? err.message) : String(err);
2425 this.logDebug(`stdin pipe error: ${reason}`);
2426 try {
2427 this.connection?.dispose();
2428 } catch {
2429 // The connection may already be closing after the child process exited.
2430 }
2431 });
2432
2433 // Create JSON-RPC connection over stdin/stdout
2434 this.messageWriter = new TeardownResilientStreamMessageWriter(this.cliProcess.stdin!);
2435 this.connection = createMessageConnection(
2436 new StreamMessageReader(this.cliProcess.stdout!),
2437 this.messageWriter
2438 );
2439
2440 this.attachConnectionHandlers();
2441 this.connection.listen();
2442 }
2443
2444 /**
2445 * Connect to parent via stdio pipes

Callers 2

connectToServerMethod · 0.95
client.test.tsFile · 0.80

Calls 4

logDebugMethod · 0.95
StringFunction · 0.85
onMethod · 0.45

Tested by

no test coverage detected