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

Commit a082916

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 f2af511 commit a082916

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
@@ -331,14 +331,14 @@ class PushQueue {
331331
return this.#bytesWritten; // Idempotent
332332
}
333333

334-
this.#cleanup();
335334
this.#rejectPendingWrites(
336335
new ERR_INVALID_STATE.TypeError('Writer closed'));
337336
this.#resolvePendingDrains(false);
338337

339338
// If buffer is empty, close immediately
340339
if (this.#slots.length === 0) {
341340
this.#writerState = 'closed';
341+
this.#cleanup();
342342
this.#resolvePendingReads();
343343
return this.#bytesWritten;
344344
}
@@ -356,6 +356,7 @@ class PushQueue {
356356
endDrained() {
357357
if (this.#writerState !== 'closing') return;
358358
this.#writerState = 'closed';
359+
this.#cleanup();
359360
if (this.#pendingEnd) {
360361
this.#pendingEnd.resolve(this.#bytesWritten);
361362
this.#pendingEnd = null;

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

Lines changed: 16 additions & 0 deletions

0 commit comments

Comments
 (0)