Skip to content

readline hangs on writes after close #57678

@dario-piotrowicz

Description

@dario-piotrowicz

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:

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?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions