Open
Description
Version
v16.13.0
Platform
Darwin MBP.local 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000 arm64
Subsystem
No response
What steps will reproduce the bug?
When executing the following code the process never exits:
const readline = require ( 'readline' );
process.stdin.setRawMode ( true );
readline.emitKeypressEvents ( process.stdin );
const cb = () => {};
process.stdin.on ( 'keypress', cb );
process.stdin.off ( 'keypress', cb );
Interestingly when executing the following it exits:
const readline = require ( 'readline' );
process.stdin.setRawMode ( true );
readline.emitKeypressEvents ( process.stdin );
const cb = () => {};
// process.stdin.on ( 'keypress', cb );
// process.stdin.off ( 'keypress', cb );
And when executing the following it exits too:
const readline = require ( 'readline' );
process.stdin.setRawMode ( true );
// readline.emitKeypressEvents ( process.stdin );
const cb = () => {};
process.stdin.on ( 'keypress', cb );
process.stdin.off ( 'keypress', cb );
So it's not attaching the event handler nor calling readline.emitKeypressEvents
on their own that cause the issue, but when both things are done for whatever reason the process never exits, even if I remove the event handler.
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
The process shouldn't hang for nothing.
What do you see instead?
The process hangs for (what seems to be) nothing.
Additional information
No response