-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Description
Version
v23.8.0
Platform
Linux AMD-Ryzen-7040-Series 6.8.0-56-generic #58-Ubuntu SMP PREEMPT_DYNAMIC Fri Feb 14 15:33:28 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
readline
What steps will reproduce the bug?
Run node index.mjs
where the content of index.mjs
is:
import readline from 'node:readline/promises';
import { stdin, stdout } from 'node:process';
const rl = readline.createInterface({ input: stdin, output: stdout, mode: 'buffering' });
process.nextTick(() => { rl.write('Hi!\n'); });
await rl.question("Hello. ");
rl.close();
rl.write('Goobye!\n');
Notice that the process hangs indefinitely, however if you remove or comment out the last line (rl.write('Goodbye!\n');
) then
the process completes without issues
How often does it reproduce? Is there a required condition?
There are no extra conditions required, the issue is always reproducible
What is the expected behavior? Why is that the expected behavior?
writing in a closing readline interface should throw an ERR_USE_AFTER_CLOSE
error in the same way question
does:
node/lib/internal/readline/interface.js
Lines 400 to 402 in e57841f
if (this.closed) { | |
throw new ERR_USE_AFTER_CLOSE('readline'); | |
} |
What do you see instead?
There is no error, and the process hangs indefinitely
Additional information
There are other operations that can be called on a closed readline interface that I believe should also error, such as pause
and resume
(what does it mean to pause a closed readline interface?)