websocketd icon indicating copy to clipboard operation
websocketd copied to clipboard

nodejs handle process.stdin incorrect

Open image72 opened this issue 2 years ago • 1 comments

Node.js read stdin synchronous

I tested above async read process.stdin. in case code, echo 'hello world' | node stdin.js work correct.

but with websocketd --port 8058 ./mock3.js read std empty.

(async function () {
   const input = await readStdinSync();
  setInterval(() => {
    process.stdout.write(JSON.stringify({ now: +new Date(), text: data.trim() }) + '\n');
  }, (3000));
})()

image72 avatar Jul 28 '23 17:07 image72

node -v
v18.17.0

image72 avatar Jul 28 '23 18:07 image72