-
Notifications
You must be signed in to change notification settings - Fork 167
Closed
Description
Noted by @reillyeon in WICG/serial#112 (comment) .
For some cases it would be nice to dequeue (and possibly abort?) a given read request, without canceling the stream entirely. That is,
const controller = new AbortController();
// Assume "rs" contains chunks A and B.
const reader = rs.getReader();
const promise1 = reader.read();
const promise2 = reader.read({ signal: controller.signal });
const promise3 = reader.read();
controller.abort();
The intent here is that promise1
gets fulfilled with chunk A, and promise3
gets fulfilled with chunk B.
Some questions:
- What does this do to
promise2
? Probably reject it with an"AbortError"
DOMException
(like in otherAbortSignal
scenarios). - What happens if abort is signaled after the read request is already fulfilled? Probably nothing (like in other
AbortSignal
scenarios). - Does this do more than just dequeue the read request? For example, could it be communicated all the way down to the underlying source, I guess via
pull()
? I don't think this helps much, but it's worth checking...
This is looking relatively straightforward to me to spec, and the use case @reillyeon presents is a good one. Should we just go for it?
MattiasBuelens and szmarczak
Metadata
Metadata
Assignees
Labels
No labels