Add transformer.cancel method to TransformStream constructor#25519
Conversation
caugner
left a comment
There was a problem hiding this comment.
LGTM overall, but I'm just not sure about the subfeature name and description.
| "cancel": { | ||
| "__compat": { | ||
| "description": "`transformer.cancel` method", |
There was a problem hiding this comment.
Given that cancel is the key in the parameter object passed to the TransformStream constructor, it confuses me slightly that this is called a method (even if the spec uses this terminology). How about:
| "cancel": { | |
| "__compat": { | |
| "description": "`transformer.cancel` method", | |
| "transformer_cancel_callback": { | |
| "__compat": { | |
| "description": "`transformer.cancel` callback", |
There was a problem hiding this comment.
The MDN articles for the ReadableStream/WritableStream/TransformStream constructors as well as the streams guides also talk about "methods", so I tried to be consistent with those. Although the specification does use the name TransformerCancelCallback for the type of that method... 😅
I think I'll stick with "method" for now. I'll make the feature name a bit more specific though, like you suggested.
Summary
The transformer object passed to the
TransformStreamconstructor can now also have acancelmethod, which is called whenever the readable side is cancelled or when the writable side is aborted. See the specification and the spec change for context.Test results and supporting details
This method is not yet supported in any browser. However, server runtimes such as Node.js and Deno already support it: