got-fetch icon indicating copy to clipboard operation
got-fetch copied to clipboard

afterResponse hook not being triggered

Open renataogarcia opened this issue 2 years ago • 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.

renataogarcia avatar Apr 29 '22 02:04 renataogarcia

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.

alexghr avatar May 04 '22 07:05 alexghr