Node SDK: MxcProcess.standardInput is ended if it is not accessed before the workload's first output
Relevant area(s)
Node SDK (macOS Seatbelt and Windows ProcessContainer)
Brief description of your issue
If the caller accesses standardInput only after the workload has written its first line, the stream is already
destroyed and the workload has seen EOF on stdin. A request/response child (an ACP or MCP server over stdio) reads EOF and
exits. The README says to "access output streams before awaiting completion"; nothing says the same for the input stream,
and an untaken input looks like it is closed on purpose.
Steps to reproduce
import { spawn } from '@microsoft/mxc-sdk/v1';
// child: prints "ready", echoes stdin, prints "stdin-end" on EOF
const child = "process.stdout.write('ready\\n'); process.stdin.on('data', d => process.stdout.write('echo ' + d)); process.stdin.on('end', () => { process.stdout.write('stdin-end\\n'); process.exit(0); });";
const proc = await spawn({ command: `node -e "${child}"`, /* workingDirectory, containment, filesystem, network */ });
let input = process.env.LAZY === '1' ? undefined : proc.standardInput;
proc.standardOutput.on('data', d => {
if (String(d).includes('ready')) setTimeout(() => { input ??= proc.standardInput; input.write('two\n'); }, 500);
});
Measured on macOS with 1.1.0:
LAZY=0 +80 ms stdout: ready +581 ms host writes (writable=true) +581 ms stdout: echo two
LAZY=1 +1343 ms stdout: ready +1344 ms stdout: stdin-end +1844 ms host writes (writable=false, destroyed=true)
The same was seen on Windows ProcessContainer with 1.0.1.
Expected behavior
Keep standardInput open until the caller ends it, or document that it must be taken immediately after spawn() resolves.
Environment
@microsoft/mxc-sdk 1.1.0, macOS 26.7 arm64 (and 1.0.1 on Windows 11).