Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add failing test for #45992 #46075

Merged
merged 1 commit into from
Jan 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions test/known_issues/test-readline-big-file-carriage-return.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

// Context: https://github.com/nodejs/node/issues/45992

require('../common');

const assert = require('assert');
const fs = require('fs');
const readline = require('readline');

const tmpdir = require('../common/tmpdir');

tmpdir.refresh();
fs.mkdtempSync(`${tmpdir.path}/`);
const path = `${tmpdir.path}/foo`;
const writeStream = fs.createWriteStream(path);

function write(iteration, callback) {
for (; iteration < 16384; iteration += 1) {
if (!writeStream.write('foo\r\n')) {
writeStream.once('drain', () => write(iteration + 1, callback));
return;
}
}

writeStream.end();
callback();
}

write(0, () => {
const input = fs.createReadStream(path);
const rl = readline.createInterface({ input, crlfDelay: Infinity });
let carriageReturns = 0;

rl.on('line', (x) => {
if (x.includes('\r')) carriageReturns += 1;
});

rl.on('close', () => {
assert.strictEqual(carriageReturns, 0);
});
});