process.stdin example from docs no longer works in node 10 · Issue #20503 · nodejs/node (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@apieceofbart

Description

@apieceofbart

I am running process.stdin example from docs:

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => { const chunk = process.stdin.read(); if (chunk !== null) { process.stdout.write(data: ${chunk}); } });

process.stdin.on('end', () => { process.stdout.write('end'); });

I expect the same results as in node v9 and below: command line should wait for my input and return it prefixed with data: . Instead, process is closed right away. I believe this is regression as example works fine in node v9 and v8.

(edited by @addaleax: syntax highlighting)