From ffa58aeb396a98d8d0b7af19e21ab8919395256e Mon Sep 17 00:00:00 2001 From: Tom Pereira <10725179+TomStrepsil@users.noreply.github.com> Date: Thu, 2 Apr 2026 19:29:28 +0100 Subject: [PATCH 1/5] doc: document TransformStream transformer.cancel option Add documentation for the `cancel` option of the `TransformStream` transformer, which allows users to specify a callback that will be called when the stream is canceled. See: https://streams.spec.whatwg.org/#transformer-api Fixes: https://github.com/nodejs/node/issues/62540 --- doc/api/webstreams.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/api/webstreams.md b/doc/api/webstreams.md index a3ce665c819b8a..02e04ffe4a83f0 100644 --- a/doc/api/webstreams.md +++ b/doc/api/webstreams.md @@ -1166,6 +1166,10 @@ added: v16.5.0 the transformation process. * `controller` {TransformStreamDefaultController} * Returns: A promise fulfilled with `undefined`. + * `cancel` {Function} A user-defined function that is called when the + readable side of the `TransformStream` is canceled. + * `reason` {any} + * Returns: A promise fulfilled with `undefined`. * `readableType` {any} the `readableType` option is reserved for future use and _must_ be `undefined`. * `writableType` {any} the `writableType` option is reserved for future use From 183d8c2e05aaf5118c418993fea343f9d4ab47ab Mon Sep 17 00:00:00 2001 From: Tom Pereira <10725179+TomStrepsil@users.noreply.github.com> Date: Thu, 2 Apr 2026 20:46:44 +0100 Subject: [PATCH 2/5] doc: clarify writeable abort applies Update to the documentation to confirm that 6.2.3 of the standard states: "A function called when the readable side is cancelled, or when the writable side is aborted." --- doc/api/webstreams.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/api/webstreams.md b/doc/api/webstreams.md index 02e04ffe4a83f0..5db1160707b73d 100644 --- a/doc/api/webstreams.md +++ b/doc/api/webstreams.md @@ -1166,8 +1166,9 @@ added: v16.5.0 the transformation process. * `controller` {TransformStreamDefaultController} * Returns: A promise fulfilled with `undefined`. - * `cancel` {Function} A user-defined function that is called when the - readable side of the `TransformStream` is canceled. + * `cancel` {Function} A user-defined function that is called when either the + readable side of the `TransformStream` is canceled or the writable side is + aborted. * `reason` {any} * Returns: A promise fulfilled with `undefined`. * `readableType` {any} the `readableType` option is reserved for future use From d74a0a797cb425991faeafbfa9ceb8f5a8e1ae24 Mon Sep 17 00:00:00 2001 From: Tom Pereira <10725179+TomStrepsil@users.noreply.github.com> Date: Thu, 2 Apr 2026 20:50:34 +0100 Subject: [PATCH 3/5] add changelog --- doc/api/webstreams.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/api/webstreams.md b/doc/api/webstreams.md index 5db1160707b73d..551846e85ca2eb 100644 --- a/doc/api/webstreams.md +++ b/doc/api/webstreams.md @@ -12,6 +12,11 @@ changes: - version: v18.0.0 pr-url: https://github.com/nodejs/node/pull/42225 description: Use of this API no longer emit a runtime warning. + - version: + - v21.5.0 + - v20.14.0 + pr-url: https://github.com/nodejs/node/pull/50126 + description: Supports the `cancel` transformer callback. --> > Stability: 2 - Stable From 7d8c0c7f93abc81902aef3300de8c1c63b7a3bc7 Mon Sep 17 00:00:00 2001 From: Tom Pereira <10725179+TomStrepsil@users.noreply.github.com> Date: Thu, 2 Apr 2026 20:51:28 +0100 Subject: [PATCH 4/5] doc: correct insertion of YAML comment --- doc/api/webstreams.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/api/webstreams.md b/doc/api/webstreams.md index 551846e85ca2eb..deb39d1e04d1ae 100644 --- a/doc/api/webstreams.md +++ b/doc/api/webstreams.md @@ -5,6 +5,11 @@ > Stability: 2 - Stable From 868db3134db042c1b0c91a65fa9a6bfc515b5d80 Mon Sep 17 00:00:00 2001 From: Tom Pereira <10725179+TomStrepsil@users.noreply.github.com> Date: Thu, 2 Apr 2026 20:57:41 +0100 Subject: [PATCH 5/5] doc: move comment to constructor --- doc/api/webstreams.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/api/webstreams.md b/doc/api/webstreams.md index deb39d1e04d1ae..55b27584361e1c 100644 --- a/doc/api/webstreams.md +++ b/doc/api/webstreams.md @@ -5,11 +5,6 @@ * `transformer` {Object}