Skip to content

readline: remove max limit of crlfDelay

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

readline

  • remove kMaxcrlfDelay
  • modify related docs
  • add one related unit test.

crlfDelay option of readline.createInterface is created by https://github.com/nodejs/node/pull/8109 . This pull request fix Interface.prototype._ttyWrite \r\n problem, but crlfDelay make some program use Interface.prototype._normalWrite behavior unexpect.

For example:

const rl = readline.createInterface({
  input: fs.createReadStream('big.csv', {
    encoding: 'utf16le',
  }),
  crlfDelay: 2000, // const kMaxcrlfDelay = 2000
});
rl.on('line', (line) => {
  // fuzzy string matching, take a lot of time
})

\r\n in csv file happen to be written in two different chunk, call them chunk A and chunk B. chunk A end with \r , chunk B start with \n . chunk A split into 1000 lines, each line event cost 3ms, after 3000ms, chunk B first line event emit with empty string '', because two chunk time gap over 2000ms, it consider \n is a new line. The time gap over kMaxcrlfDelay is not rare.

kMaxcrlfDelay is meaningless in both tty write and normal write, remove it is a better design.

Merge request reports

Loading