Closed triblondon closed 5 years ago
Ah, of course I can (and should) catch this in application code. Ignore me.
No worries @triblondon, yes you should catch the possible rejection from response .readable()
, .text()
etc.
gzip and ranges sounds scary, I'm not sure what the common way is to solve it.
If you really need to manually handle incomplete data, you can make your own custom decoder and call it gzip
. This will overwrite the built-in one. Yours can simply forward the raw compressed stream, and then you can manually glue the pieces together and finally decode. But it sounds clumsy.
Reproduces when
fetch-h2
is handing a response that hasContent-Encoding: gzip
and is an incomplete response (eg if the request contains aRange: 0-0
header).An obvious solution seems to be to handle the
error
event on the decoder stream, but looking atresponse.ts
, I'm not totally sure how to do this, given that thecontentDecoders
param may inject decoders into the function, which doesn't seem to give an obvious place to set up an error handler.