Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ function on(emitter, event, options = kEmptyObject) {
const value = unconsumedEvents.shift();
size--;
if (paused && size < lowWatermark) {
emitter.resume();
emitter.resume(); // Can not be finished yet
paused = false;
}
return PromiseResolve(createIterResult(value, false));
Expand Down Expand Up @@ -1188,6 +1188,7 @@ function on(emitter, event, options = kEmptyObject) {
abortListenerDisposable?.[SymbolDispose]();
removeAll();
finished = true;
paused = false;
const doneResult = createIterResult(undefined, true);
while (!unconsumedPromises.isEmpty()) {
unconsumedPromises.shift().resolve(doneResult);
Expand Down
25 changes: 25 additions & 0 deletions test/parallel/test-readline-async-iterators.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@

const filename = tmpdir.resolve('test.txt');

const testContents = [

Check failure on line 14 in test/parallel/test-readline-async-iterators.js

View workflow job for this annotation

GitHub Actions / test-linux (ubuntu-24.04)

--- stderr --- /home/runner/work/node/node/node/test/parallel/test-readline-async-iterators.js:14 const testContents = [ ^ ReferenceError: AArray is not defined at Object.<anonymous> (/home/runner/work/node/node/node/test/parallel/test-readline-async-iterators.js:14:22) at Module._compile (node:internal/modules/cjs/loader:1760:14) at Object..js (node:internal/modules/cjs/loader:1892:10) at Module.load (node:internal/modules/cjs/loader:1480:32) at Module._load (node:internal/modules/cjs/loader:1299:12) at TracingChannel.traceSync (node:diagnostics_channel:328:14) at wrapModuleLoad (node:internal/modules/cjs/loader:245:24) at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5) at node:internal/main/run_main_module:33:47 Node.js v26.0.0-pre Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /home/runner/work/node/node/node/test/parallel/test-readline-async-iterators.js

Check failure on line 14 in test/parallel/test-readline-async-iterators.js

View workflow job for this annotation

GitHub Actions / test-linux (ubuntu-24.04-arm)

--- stderr --- /home/runner/work/node/node/node/test/parallel/test-readline-async-iterators.js:14 const testContents = [ ^ ReferenceError: AArray is not defined at Object.<anonymous> (/home/runner/work/node/node/node/test/parallel/test-readline-async-iterators.js:14:22) at Module._compile (node:internal/modules/cjs/loader:1760:14) at Object..js (node:internal/modules/cjs/loader:1892:10) at Module.load (node:internal/modules/cjs/loader:1480:32) at Module._load (node:internal/modules/cjs/loader:1299:12) at TracingChannel.traceSync (node:diagnostics_channel:328:14) at wrapModuleLoad (node:internal/modules/cjs/loader:245:24) at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5) at node:internal/main/run_main_module:33:47 Node.js v26.0.0-pre Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /home/runner/work/node/node/node/test/parallel/test-readline-async-iterators.js

Check failure on line 14 in test/parallel/test-readline-async-iterators.js

View workflow job for this annotation

GitHub Actions / test-macOS

--- stderr --- /Users/runner/work/node/node/node/test/parallel/test-readline-async-iterators.js:14 const testContents = [ ^ ReferenceError: AArray is not defined at Object.<anonymous> (/Users/runner/work/node/node/node/test/parallel/test-readline-async-iterators.js:14:22) at Module._compile (node:internal/modules/cjs/loader:1760:14) at Object..js (node:internal/modules/cjs/loader:1892:10) at Module.load (node:internal/modules/cjs/loader:1480:32) at Module._load (node:internal/modules/cjs/loader:1299:12) at TracingChannel.traceSync (node:diagnostics_channel:328:14) at wrapModuleLoad (node:internal/modules/cjs/loader:245:24) at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5) at node:internal/main/run_main_module:33:47 Node.js v26.0.0-pre Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /Users/runner/work/node/node/node/test/parallel/test-readline-async-iterators.js

Check failure on line 14 in test/parallel/test-readline-async-iterators.js

View workflow job for this annotation

GitHub Actions / aarch64-darwin: with shared libraries

--- stderr --- /Users/runner/work/_temp/node-v26.0.0-nightly2025-11-03252a72c61b-slim/test/parallel/test-readline-async-iterators.js:14 const testContents = [ ^ ReferenceError: AArray is not defined at Object.<anonymous> (/Users/runner/work/_temp/node-v26.0.0-nightly2025-11-03252a72c61b-slim/test/parallel/test-readline-async-iterators.js:14:22) at Module._compile (node:internal/modules/cjs/loader:1760:14) at Object..js (node:internal/modules/cjs/loader:1892:10) at Module.load (node:internal/modules/cjs/loader:1480:32) at Module._load (node:internal/modules/cjs/loader:1299:12) at TracingChannel.traceSync (node:diagnostics_channel:328:14) at wrapModuleLoad (node:internal/modules/cjs/loader:245:24) at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5) at node:internal/main/run_main_module:33:47 Node.js v26.0.0-pre Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /Users/runner/work/_temp/node-v26.0.0-nightly2025-11-03252a72c61b-slim/test/parallel/test-readline-async-iterators.js

Check failure on line 14 in test/parallel/test-readline-async-iterators.js

View workflow job for this annotation

GitHub Actions / x86_64-linux: with shared libraries

--- stderr --- /home/runner/work/_temp/node-v26.0.0-nightly2025-11-03252a72c61b-slim/test/parallel/test-readline-async-iterators.js:14 const testContents = [ ^ ReferenceError: AArray is not defined at Object.<anonymous> (/home/runner/work/_temp/node-v26.0.0-nightly2025-11-03252a72c61b-slim/test/parallel/test-readline-async-iterators.js:14:22) at Module._compile (node:internal/modules/cjs/loader:1760:14) at Object..js (node:internal/modules/cjs/loader:1892:10) at Module.load (node:internal/modules/cjs/loader:1480:32) at Module._load (node:internal/modules/cjs/loader:1299:12) at TracingChannel.traceSync (node:diagnostics_channel:328:14) at wrapModuleLoad (node:internal/modules/cjs/loader:245:24) at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5) at node:internal/main/run_main_module:33:47 Node.js v26.0.0-pre Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /home/runner/work/_temp/node-v26.0.0-nightly2025-11-03252a72c61b-slim/test/parallel/test-readline-async-iterators.js

Check failure on line 14 in test/parallel/test-readline-async-iterators.js

View workflow job for this annotation

GitHub Actions / aarch64-linux: with shared libraries

--- stderr --- /home/runner/work/_temp/node-v26.0.0-nightly2025-11-03252a72c61b-slim/test/parallel/test-readline-async-iterators.js:14 const testContents = [ ^ ReferenceError: AArray is not defined at Object.<anonymous> (/home/runner/work/_temp/node-v26.0.0-nightly2025-11-03252a72c61b-slim/test/parallel/test-readline-async-iterators.js:14:22) at Module._compile (node:internal/modules/cjs/loader:1760:14) at Object..js (node:internal/modules/cjs/loader:1892:10) at Module.load (node:internal/modules/cjs/loader:1480:32) at Module._load (node:internal/modules/cjs/loader:1299:12) at TracingChannel.traceSync (node:diagnostics_channel:328:14) at wrapModuleLoad (node:internal/modules/cjs/loader:245:24) at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5) at node:internal/main/run_main_module:33:47 Node.js v26.0.0-pre Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /home/runner/work/_temp/node-v26.0.0-nightly2025-11-03252a72c61b-slim/test/parallel/test-readline-async-iterators.js

Check failure on line 14 in test/parallel/test-readline-async-iterators.js

View workflow job for this annotation

GitHub Actions / x86_64-darwin: with shared libraries

--- stderr --- /Users/runner/work/_temp/node-v26.0.0-nightly2025-11-03252a72c61b-slim/test/parallel/test-readline-async-iterators.js:14 const testContents = [ ^ ReferenceError: AArray is not defined at Object.<anonymous> (/Users/runner/work/_temp/node-v26.0.0-nightly2025-11-03252a72c61b-slim/test/parallel/test-readline-async-iterators.js:14:22) at Module._compile (node:internal/modules/cjs/loader:1760:14) at Object..js (node:internal/modules/cjs/loader:1892:10) at Module.load (node:internal/modules/cjs/loader:1480:32) at Module._load (node:internal/modules/cjs/loader:1299:12) at TracingChannel.traceSync (node:diagnostics_channel:328:14) at wrapModuleLoad (node:internal/modules/cjs/loader:245:24) at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5) at node:internal/main/run_main_module:33:47 Node.js v26.0.0-pre Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout /Users/runner/work/_temp/node-v26.0.0-nightly2025-11-03252a72c61b-slim/test/parallel/test-readline-async-iterators.js
'',
'\n',
'line 1',
'line 1\nline 2 南越国是前203年至前111年存在于岭南地区的一个国家\nline 3\ntrailing',
'line 1\nline 2\nline 3 ends with newline\n',
AArray(1e4).fill(0).map((_, i) => i).join('\n'), // More that 2 * highWaterMark

Check failure on line 20 in test/parallel/test-readline-async-iterators.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

'AArray' is not defined
];

async function testSimple() {
Expand All @@ -43,6 +44,29 @@
}
}

// Same as testSimple, but with Readable.from() instead of fs.createReadStream
async function testReadableFrom() {
for (const fileContent of testContents) {
const readable = Readable.from([fileContent]);
const rli = readline.createInterface({
input: readable,
crlfDelay: Infinity
});

const iteratedLines = [];
for await (const k of rli) {
iteratedLines.push(k);
}

const expectedLines = fileContent.split('\n');
if (expectedLines[expectedLines.length - 1] === '') {
expectedLines.pop();
}
assert.deepStrictEqual(iteratedLines, expectedLines);
assert.strictEqual(iteratedLines.join(''), fileContent.replace(/\n/g, ''));
}
}

async function testMutual() {
for (const fileContent of testContents) {
fs.writeFileSync(filename, fileContent);
Expand Down Expand Up @@ -115,6 +139,7 @@
}

testSimple()
.then(testReadableFrom)
.then(testMutual)
.then(testSlowStreamForLeaks)
.then(common.mustCall());
Loading