Unexpected end of file at zlib._handle.onerror
Closed this issue · 3 comments
Hello! I use this code and url response gzip.
const request = popsicle.request({
method: 'GET',
url: url,
transport: popsicle.createTransport({
type: 'stream'
})
});
return request.then(function (res) {
res.body.on('error', err => {});
if (res.status !== 200) {
request.abort();
throw new Error('Bad status');
}
...
});
If status will not 200 and I don't add after then this code:
res.body.on('error', err => {});
Will throw zlib error as Uncaught exception without stack. It is ok?
This is the expected behaviour, you need to handle any streaming issues when you abort because the response would end prematurely. I don't have a good idea on how to resolve this yet, but have thought about it in the past (what you did is exactly what I've been doing). One other idea would be to catch this error inside the module by injecting into error
handler when you call abort
. What do you think?
I don't know, how to do better. But just need know about this exception. Maybe need write about it in documentation.
I believe this has been improved with the new API design based on servie
.