Skip to content

Commit bc4e733

Browse files
committed
test: add failing test for #45992
1 parent 3a44f9a commit bc4e733

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
3+
// Context: https://github.com/nodejs/node/issues/45992
4+
5+
const assert = require('assert');
6+
const fs = require('fs');
7+
const readline = require('readline');
8+
9+
const tmpdir = require('../common/tmpdir');
10+
11+
tmpdir.refresh();
12+
fs.mkdtempSync(`${tmpdir.path}/`);
13+
const path = `${tmpdir.path}/foo`;
14+
const writeStream = fs.createWriteStream(path);
15+
16+
function write(iteration, callback) {
17+
for (; iteration < 16384; iteration += 1) {
18+
if (!writeStream.write('foo\r\n')) {
19+
writeStream.once('drain', () => write(iteration + 1, callback));
20+
return;
21+
}
22+
}
23+
24+
writeStream.end();
25+
callback();
26+
}
27+
28+
write(0, () => {
29+
const input = fs.createReadStream(path);
30+
const rl = readline.createInterface({ input, crlfDelay: Infinity });
31+
let carriageReturns = 0;
32+
33+
rl.on('line', (x) => {
34+
if (x.includes('\r')) carriageReturns += 1;
35+
});
36+
37+
rl.on('close', () => {
38+
assert.strictEqual(carriageReturns, 0);
39+
});
40+
});

0 commit comments

Comments
 (0)