I have a program (programA) that I do not control and writes to stdout.
I have another script that I wrote that wants to read from the stdin (whatever the other program produces) and also writes to the stdout.
ProgramA executes the script. I have the following:
// Create an interface for readline
const rl = createInterface({
input: process.stdin,
output: process.stdout,
});
rl.prompt();
rl.on("line", (line) => {
// Process the line of input here
console.log(`Received: ${line}`);
...
But this is causing EPIPE error
node:events:496
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at afterWriteDispatched (node:internal/stream_base_commons:160:15)
at writeGeneric (node:internal/stream_base_commons:151:3)
Any hint on how can I still write to stdout without causing the EPIPE issue?