-
Notifications
You must be signed in to change notification settings - Fork 107
Replay does not return any data if stream is not immediately read #139
Comments
I've also encountered this issue just now. I'm keeping the I'm wondering if changing it to not resume would break current usage or not. The current test suite fails on my machine. A few more tests fail when removing that |
This is biting me too. Thanks for tracking down the cause @nicolasazrak. |
@assaf Is there a reason that Replay is defaulting returned streams to If you're not inclined to change that default behavior in Replay, would you be open to a pull-request that adds an option to disable the automatic flow of response data? I'd propose defaulting to automatic resume on capture (so it's not a breaking change), but allow users to restore the |
I was trying to use https://github.com/sindresorhus/got with replay without success. When using replay the responses bodies are always empty. After reading the code of both libraries I discovered that replay returns a response and sets its stream in flowing state (https://nodejs.org/api/stream.html#stream_two_modes). The problem with that mode is that if the content is not immediately read, it will be lost. Libraries using
http
module expect the stream not to be flowing. This example reproduces the issue:Without the
setImmediate
it works as expected. But it's different to how thehttp
module works. Just removing this line solves the issue.The text was updated successfully, but these errors were encountered: