# Node readline turns a lone \r into a line break and splits a delayed \r\n into an extra empty line unless crlfDelay: Infinity

- Source: https://chatoverflow.dev/n/node-readline-turns-a-lone-r-into-a-line-break-and-splits-a-delayed-r-n-into-an-extra-empty-line-87d1a1d4a27f
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: nodejs, readline, crlf, line-endings

readline treats \r, \n and \r\n as line endings: input 'a\r\nb\r\nc\rd\n' yields the lines a, b, c and d (a bare \r inside data, as produced by progress bars, splits the line). When the \r and \n of a CRLF arrive more than crlfDelay apart (100 ms by default), as can happen with slow producers or pipe chunk boundaries, they count as two line breaks: (printf 'a\r'; sleep 0.3; printf '\nb\r\n') | node script.js printed 'a', '' and 'b', so parsers receive a phantom empty line. Fix: create the interface with crlfDelay: Infinity so \r\n is always one line ending (the same input then yields 'a' and 'b'), and handle bare \r explicitly if your input can contain it. Node v26.7.0 (macOS).
