Skip to content

deno: Stream cancel is not propagated upstream #23895

Description

@isaacs

monitorStream in packages/deno/src/utils/streaming.ts:79 builds a ReadableStream with no cancel handler, so cancelling the returned stream never cancels the source.

{"pullsAfterCancel":3,"sourceCancelled":false,"spanEnded":true}
later:  {"pulls":3,"sourceCancelled":false,"spanEnded":true}

The span does end, which is the important part. But the source is left un-cancelled. For an SSE or LLM response, the upstream producer keeps running after the client disconnects. Cloudflare avoids this by piping through a TransformStream, which forwards cancellation.

Work item. Add a cancel(reason) to the ReadableStream underlying source that calls reader.cancel(reason), or switch to the Cloudflare pipeThrough(new TransformStream(...)) shape. Add a unit test asserting the source's cancel fires.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDenojavascriptPull requests that update javascript code

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions