Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4484e14

Browse filesBrowse files
ChALkeRaduh95
authored andcommitted
events: don't call resume after close
PR-URL: #60548 Fixes: #60507 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
1 parent b4a826b commit 4484e14
Copy full SHA for 4484e14

2 files changed

+27-1Lines changed: 27 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/events.js‎

Copy file name to clipboardExpand all lines: lib/events.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ function on(emitter, event, options = kEmptyObject) {
10741074
const value = unconsumedEvents.shift();
10751075
size--;
10761076
if (paused && size < lowWatermark) {
1077-
emitter.resume();
1077+
emitter.resume(); // Can not be finished yet
10781078
paused = false;
10791079
}
10801080
return PromiseResolve(createIterResult(value, false));
@@ -1191,6 +1191,7 @@ function on(emitter, event, options = kEmptyObject) {
11911191
abortListenerDisposable?.[SymbolDispose]();
11921192
removeAll();
11931193
finished = true;
1194+
paused = false;
11941195
const doneResult = createIterResult(undefined, true);
11951196
while (!unconsumedPromises.isEmpty()) {
11961197
unconsumedPromises.shift().resolve(doneResult);
Collapse file

‎test/parallel/test-readline-async-iterators.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-readline-async-iterators.js
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const testContents = [
1717
'line 1',
1818
'line 1\nline 2 南越国是前203年至前111年存在于岭南地区的一个国家\nline 3\ntrailing',
1919
'line 1\nline 2\nline 3 ends with newline\n',
20+
Array(1e4).fill(0).map((_, i) => i).join('\n'), // More that 2 * highWaterMark
2021
];
2122

2223
async function testSimple() {
@@ -43,6 +44,29 @@ async function testSimple() {
4344
}
4445
}
4546

47+
// Same as testSimple, but with Readable.from() instead of fs.createReadStream
48+
async function testReadableFrom() {
49+
for (const fileContent of testContents) {
50+
const readable = Readable.from([fileContent]);
51+
const rli = readline.createInterface({
52+
input: readable,
53+
crlfDelay: Infinity
54+
});
55+
56+
const iteratedLines = [];
57+
for await (const k of rli) {
58+
iteratedLines.push(k);
59+
}
60+
61+
const expectedLines = fileContent.split('\n');
62+
if (expectedLines[expectedLines.length - 1] === '') {
63+
expectedLines.pop();
64+
}
65+
assert.deepStrictEqual(iteratedLines, expectedLines);
66+
assert.strictEqual(iteratedLines.join(''), fileContent.replace(/\n/g, ''));
67+
}
68+
}
69+
4670
async function testMutual() {
4771
for (const fileContent of testContents) {
4872
fs.writeFileSync(filename, fileContent);
@@ -115,6 +139,7 @@ async function testSlowStreamForLeaks() {
115139
}
116140

117141
testSimple()
142+
.then(testReadableFrom)
118143
.then(testMutual)
119144
.then(testSlowStreamForLeaks)
120145
.then(common.mustCall());

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.