stream: ensure factory signals remain active through closing · nodejs/node@042b951 · GitHub
Skip to content

Commit 042b951

Browse files
jasnelladuh95
authored andcommitted
stream: ensure factory signals remain active through closing
Signed-off-by: James M Snell <jasnell@gmail.com> Assisted-by: Opencode PR-URL: #65658 Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 2dc09ca commit 042b951

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

‎doc/api/stream_iter.md‎

Lines changed: 3 additions & 1 deletion

‎lib/internal/streams/iter/push.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,14 @@ class PushQueue {
334334
return this.#bytesWritten; // Idempotent
335335
}
336336

337-
this.#cleanup();
338337
this.#rejectPendingWrites(
339338
new ERR_INVALID_STATE.TypeError('Writer closed'));
340339
this.#resolvePendingDrains(false);
341340

342341
// If buffer is empty, close immediately
343342
if (this.#slots.length === 0) {
344343
this.#writerState = 'closed';
344+
this.#cleanup();
345345
this.#resolvePendingReads();
346346
return this.#bytesWritten;
347347
}
@@ -359,6 +359,7 @@ class PushQueue {
359359
endDrained() {
360360
if (this.#writerState !== 'closing') return;
361361
this.#writerState = 'closed';
362+
this.#cleanup();
362363
if (this.#pendingEnd) {
363364
this.#pendingEnd.resolve(this.#bytesWritten);
364365
this.#pendingEnd = null;

‎test/parallel/test-stream-iter-push-writer.js‎

Lines changed: 16 additions & 0 deletions

0 commit comments

Comments
 (0)