Skip to content

fix(deno): Propagate stream cancellation - #24054

Merged
andreiborza merged 1 commit into
getsentry:developfrom
psang39:fix/deno-stream-cancel-propagation
Sep 4, 2026
Merged

fix(deno): Propagate stream cancellation#24054
andreiborza merged 1 commit into
getsentry:developfrom
psang39:fix/deno-stream-cancel-propagation

Conversation

@psang39

@psang39 psang39 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).
  • Link an issue if there is one related to your pull request. If no issue is linked, one will be auto-generated and linked.

monitorStream creates a wrapping ReadableStream, but did not forward
cancellation to the source reader. This meant upstream producers could
continue running after the response consumer disconnected.

This adds a cancel(reason) handler which delegates to
reader.cancel(reason), along with a regression test verifying that the
cancellation reason reaches the source stream.

Closes #23895

Forward cancellation from monitored response streams to their source readers so upstream producers can stop work and release resources.

Fixes getsentry#23895
@psang39
psang39 marked this pull request as ready for review September 4, 2026 06:31
@psang39
psang39 requested a review from a team as a code owner September 4, 2026 06:31
@psang39
psang39 requested review from isaacs and mydea and removed request for a team September 4, 2026 06:32
@JosephDoUrden

Copy link
Copy Markdown

Ran this on 065ef1f. @psang39's new test passes, full deno suite 65 green, oxlint clean.

Also tried it against an endless pull-based source since that is the shape from the issue. Read two chunks, cancelled with a reason, waited 50ms. Pull count settled at 3 against 4 on the parent, the source cancel got the same reason object, the span ended once, no unhandled rejections. Deno's op and resource sanitizers stayed quiet too.

Same probe on the parent commit and the source cancel never fires, so this is doing what it says.

Looks merge-ready to me.

@andreiborza andreiborza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi, looks good to me. Thank you for the contribution!

@andreiborza
andreiborza merged commit c619da3 into getsentry:develop Sep 4, 2026
94 of 96 checks passed
andreiborza added a commit that referenced this pull request Sep 4, 2026
This PR adds the external contributor to the CHANGELOG.md file, so that
they are credited for their contribution. See #24054

Co-authored-by: andreiborza <168741329+andreiborza@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deno: Stream cancel is not propagated upstream

3 participants