yutakahirano / fetch-with-streams

Fetch API integrated with Streams.
66 stars 8 forks source link

can Response.body.cancel() terminate an ongoing Response.json()? #51

Closed wanderview closed 9 years ago

wanderview commented 9 years ago

It seems maybe Response.json() having a lock on the stream would prevent it from being canceled through body.cancel(). Is this ok?

cc / @domenic @annevk

annevk commented 9 years ago

That's why we'll have response.json().cancel(), no?

wanderview commented 9 years ago

Maybe I got confused from this conversation about cancelable promises on #whatwg:

http://logs.glob.uno/?c=freenode%23whatwg#c957231

yutakahirano commented 9 years ago

Response.body.cancel() is callable only when the body is not locked by anyone. Hence it is not callabled when Response.json() is running.

domenic commented 9 years ago

To answer the OP's question: yes, it would prevent it from being canceled (except by response.json().cancel(), i.e. eventual cancelable promises) and yes, this is OK.