Skip to content

readline regression since v24.2.0 on >= 1026 lines in input #60507

@ChALkeR

Description

@ChALkeR

To reproduce, apply the following diff to benchmarks:

diff --git a/benchmark/readline/readline-iterable.js b/benchmark/readline/readline-iterable.js
index 9be4ea1f52b..a023424edd3 100644
--- a/benchmark/readline/readline-iterable.js
+++ b/benchmark/readline/readline-iterable.js
@@ -20,7 +20,7 @@ Amet nisl suscipit adipiscing bibendum est ultricies integer.
 Sit amet dictum sit amet justo donec enim diam.
 Condimentum mattis pellentesque id nibh tortor id aliquet lectus proin.
 Diam in arcu cursus euismod quis viverra nibh.
-Rest of line`;
+Rest of line`.repeat(900);
 
 function oldWay() {
   const readable = new Readable({

Observed behavior:

readline/readline-iterable.js type="old" n=10: 3,372,871.300286141
node:internal/readline/interface:579
      throw new ERR_USE_AFTER_CLOSE('readline');
            ^

Error [ERR_USE_AFTER_CLOSE]: readline was closed
    at Interface.resume (node:internal/readline/interface:579:13)
    at Object.next (node:events:1074:19)
    at main (benchmark/readline/readline-iterable.js:78:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
  code: 'ERR_USE_AFTER_CLOSE'
}

Node.js v24.10.0

Simplified testcase:

import readline from 'node:readline'
import { Readable } from 'node:stream'

const input = Readable.from([`Line\n`.repeat(1e4)])
const iterable = readline.createInterface({ input })
for await (const _ of iterable);

Any number of lines higher than 1025 (i.e. > highWaterMark + 1) reproduces this

main, 25, and 24 latest are affected.

First affected version is v24.2.0.

v24.1.0 was fine, v22 latest is fine.

#59431 might be related with a common cause, but that involves terminal, and this doesn't
I.e. after fixing this #59431 should be rechecked. The error is different though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions