Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transformer.cancel method to TransformStream constructor #25519

Merged
merged 4 commits into from
Jan 3, 2025

Conversation

MattiasBuelens
Copy link
Contributor

Summary

The transformer object passed to the TransformStream constructor can now also have a cancel method, 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:

@github-actions github-actions bot added data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API data:browsers Data about browsers (versions, release dates, etc). This data is used for validation. size:m [PR only] 25-100 LoC changed labels Dec 28, 2024
Copy link
Contributor

@caugner caugner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, but I'm just not sure about the subfeature name and description.

Comment on lines 91 to 93
"cancel": {
"__compat": {
"description": "`transformer.cancel` method",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
"cancel": {
"__compat": {
"description": "`transformer.cancel` method",
"transformer_cancel_callback": {
"__compat": {
"description": "`transformer.cancel` callback",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

@caugner caugner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, LGTM!

@caugner caugner merged commit 0de51d0 into mdn:main Jan 3, 2025
9 checks passed
@mdn-bot mdn-bot mentioned this pull request Jan 3, 2025
@MattiasBuelens MattiasBuelens deleted the transformstream-transformer-cancel branch January 3, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API data:browsers Data about browsers (versions, release dates, etc). This data is used for validation. size:m [PR only] 25-100 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants