alexghr/got-fetch

afterResponse hook not being triggered

renataogarcia opened this issue · 1 comments

After upgrading to 5.1 the afterResponse hook is no longer being triggered. The beforeRequest works fine.

It seems that 5.1 introduced this change where it is always using streams and as per got docs the afterResponse is ignored when using streams.

Hi @renataogarcia, I see what you mean. We could check if the request body is a stream and switch between got's streaming API and classic API to restore the hook functionality. I

think this could work if we wrap the response body in a stream in GotResponse if the calling code requests the body as a stream.

I'll give this a try.