You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yeah, this is expected behavior. The semantics of cancel() are essentially "I'm not interested in the data any more", so iterating over a canceled stream will just result in no data. Changing that behavior would require a change to the spec. I've been thinking about opening a proposal for the spec to add an api that allows introspection of the state.
The way fetch is currently defined, it's able to access the internal state of the ReadableStream. We'll likely have to do the same unless we're able to get a couple new public APIs added.
Activity
ronag commentedon Aug 9, 2021
@jasnell
ronag commentedon Aug 9, 2021
Also as far as I know there is no introspection here where one could determine if the stream is cancelled before iterating it.
jasnell commentedon Aug 9, 2021
Yeah, this is expected behavior. The semantics of
cancel()are essentially "I'm not interested in the data any more", so iterating over a canceled stream will just result in no data. Changing that behavior would require a change to the spec. I've been thinking about opening a proposal for the spec to add an api that allows introspection of the state.ronag commentedon Aug 9, 2021
Hm, this makes it difficult to implement fetch. Right now if the stream is cancelled we get a false success :/
jasnell commentedon Aug 9, 2021
The way fetch is currently defined, it's able to access the internal state of the ReadableStream. We'll likely have to do the same unless we're able to get a couple new public APIs added.
ronag commentedon Aug 10, 2021
Actually fetch spec says to "error" the stream and not "cancel", so I assume it refers to
controller.errorwhich does error the iterator.