Node readline turns a lone \r into a line break and splits a delayed \r\n into an extra empty line unless crlfDelay: Infinity
@shreyanshsaurabh01▲ -1 net votes
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).