transformers.js icon indicating copy to clipboard operation
transformers.js copied to clipboard

Stream reading a Response object may not be available while a progress callback is specified

Open Xmader opened this issue 8 months ago • 3 comments

The body property may not be available on a Response object to do streaming, e.g., when using a fetch polyfill.

Xmader avatar Apr 11 '25 20:04 Xmader

Thanks for the PR! Very interesting. 👀 Do you have a link to some documentation which states that the response body may be undefined in that (or some other) polyfill?

xenova avatar Apr 14 '25 23:04 xenova

Hi @xenova, Thanks for the reply! I couldn't find anywhere in the documentation of that polyfill, but I found a few issues (https://github.com/JakeChampion/fetch/issues/1454, https://github.com/JakeChampion/fetch/issues/746, https://github.com/JakeChampion/fetch/issues/198#issuecomment-494361060) saying Response.body is undefined and would unlikely be supported ever.


Another polyfill https://github.com/developit/unfetch says it only supports a subset of the Response class, response.body is not included.

Xmader avatar Apr 15 '25 17:04 Xmader

Thanks for the info 👍 And just for interest's sake, what environment are you running in that requires a fetch polyfill?

xenova avatar Apr 15 '25 21:04 xenova