From 271a702042e2f93cadffe32a2f420c862cfe2339 Mon Sep 17 00:00:00 2001 From: Benjamin Gruenbaum Date: Sun, 25 Jun 2023 14:35:59 +0000 Subject: [PATCH 1/2] stream: support dispose in writable Add support to Symbol.asyncDispose in writable streams. Additionally add a test for writable, transform and duplex streams who inherit from readable/writable to avoid breakage. Co-authored-by: Robert Nagy Co-authored-by: atlowChemi --- doc/api/stream.md | 11 ++++++ lib/internal/streams/writable.js | 35 +++++++++++++------ test/parallel/test-stream-duplex-destroy.js | 15 ++++++++ .../parallel/test-stream-transform-destroy.js | 11 ++++++ test/parallel/test-stream-writable-destroy.js | 12 +++++++ 5 files changed, 74 insertions(+), 10 deletions(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index f7566858ee594b..9539457daf8749 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -954,6 +954,17 @@ added: v12.3.0 Getter for the property `objectMode` of a given `Writable` stream. +##### `writable[Symbol.asyncDispose]()` + + + +> Stability: 1 - Experimental + +Calls [`writable.destroy()`][writable-destroy] with an `AbortError` and returns +a promise that fulfills when the stream is finished. + ##### `writable.write(chunk[, encoding][, callback])`