2023-03-01 23:18:05 +09:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const ArrayStream = require('../common/arraystream');
|
|
|
|
const assert = require('assert');
|
|
|
|
|
2025-01-22 14:19:38 -08:00
|
|
|
if (process.env.TERM === 'dumb') {
|
|
|
|
common.skip('skipping - dumb terminal');
|
|
|
|
}
|
2023-03-01 23:18:05 +09:00
|
|
|
|
|
|
|
const readline = require('readline');
|
|
|
|
const rli = new readline.Interface({
|
|
|
|
terminal: true,
|
|
|
|
input: new ArrayStream(),
|
|
|
|
});
|
|
|
|
|
|
|
|
let recursionDepth = 0;
|
|
|
|
|
|
|
|
// Minimal reproduction for #46731
|
|
|
|
const testInput = ' \n}\n';
|
|
|
|
const numberOfExpectedLines = testInput.match(/\n/g).length;
|
|
|
|
|
|
|
|
rli.on('line', () => {
|
|
|
|
// Abort in case of infinite loop
|
|
|
|
if (recursionDepth > numberOfExpectedLines) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
recursionDepth++;
|
|
|
|
// Write something recursively to readline
|
|
|
|
rli.write('foo');
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
rli.write(testInput);
|
|
|
|
|
|
|
|
assert.strictEqual(recursionDepth, numberOfExpectedLines);
|