Skip to content

Streams: test whether pipe stop pulling on abort#32399

Draft
MattiasBuelens wants to merge 4 commits into
web-platform-tests:masterfrom
MattiasBuelens:rs-pipe-stop-pulling-on-abort
Draft

Streams: test whether pipe stop pulling on abort#32399
MattiasBuelens wants to merge 4 commits into
web-platform-tests:masterfrom
MattiasBuelens:rs-pipe-stop-pulling-on-abort

Conversation

@MattiasBuelens

@MattiasBuelens MattiasBuelens commented Jan 16, 2022

Copy link
Copy Markdown
Contributor

See whatwg/streams#1208 for the accompanying spec change.

These tests demonstrates one way how pipeTo() can inadvertently drop a chunk continue reading for too long.

  1. The source starts with one chunk 'a' in its queue.
  2. The destination has highWaterMark = Infinity, so writer.ready is always resolved.
  3. We start a pipe with preventCancel = true and a given AbortSignal.
  4. The pipe reads the first chunk from the source's queue. It starts writing it to the destination.
  5. The pipe starts a read request for the second chunk, which is not yet available.
  6. We abort the AbortSignal.
  7. We enqueue a second chunk 'b'.
  8. The pending write (for 'a') completes.

Expected behavior:

  • The pipe promise rejects with the signal's abort reason.
  • The destination receives only chunk 'a'.
  • The source's queue contains the chunk 'b'.

Actual behavior:

  • The pipe promise rejects with the signal's abort reason.
  • The destination receives both chunk 'a' and 'b'.
  • The source's queue is empty.

@domenic

domenic commented Jan 18, 2022

Copy link
Copy Markdown
Member

inadvertently drop a chunk.

Is it dropped? Or is it just sent to the destination over-aggressively?

@MattiasBuelens

Copy link
Copy Markdown
Contributor Author

Oops, you're right. 😅 I was initially testing with erroring the writable stream to stop the pipe, but in the end I went with aborting it using a signal instead.

I think it's possible to trigger something similar with an errored writable stream, but I think we can solve that with your suggestion in whatwg/streams#1207 (comment) to synchronously check the destination's state.

@MattiasBuelens
MattiasBuelens force-pushed the rs-pipe-stop-pulling-on-abort branch from 1646d65 to 6f27b30 Compare May 17, 2026 20:01
@MattiasBuelens
MattiasBuelens force-pushed the rs-pipe-stop-pulling-on-abort branch from 75a8e1a to 6f27b30 Compare May 25, 2026 20:38
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.

2 participants