From d06ab236dc1f572856996ed73202aca34350c973 Mon Sep 17 00:00:00 2001 From: Benjamin Gruenbaum Date: Sun, 16 Jun 2024 02:41:59 +0300 Subject: [PATCH] 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 PR-URL: https://github.com/nodejs/node/pull/48547 Reviewed-By: Chemi Atlow Reviewed-By: Moshe Atlow Reviewed-By: Robert Nagy Reviewed-By: Matteo Collina --- doc/api/stream.md | 11 ++++++ lib/internal/streams/writable.js | 37 ++++++++++++++----- 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, 76 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])`