Fix pause before response arrives #1569
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a bit of fallout due to overlooking the pause behavior before the response arrives in #1568 last night. I added some additional tests which should help catch similar issues in the future.
If anyone has ideas for how to avoid the arbitrary
setTimeout
s when testingpause
/resume
, that would be great (currently it waits a bit between sending chunks to allow pausing and waits a bit more after callingpause
to confirm no more data arrives). Also, if there is a better location for the tests, I'm open to moving them around too.Due to #1568, we now propagate pause and resume to the response content stream, rather than the response stream. However, when pause is called before the response arrives, the pause is still being applied to the response object directly. Fix this by applying it to the response content stream in both cases. This avoids the issue that if pause is called on a gzip request before the response arrives, it pauses the response then resumes the response content, meaning the response can not be resumed.
Also add tests of the pause/resume behavior for both the gzip and non-gzip case both before and after the response has arrived.
This commit also makes the ancillary change that resume is now called unconditionally (when defined) in
Redirect
, since we always want to dump the response data (and it was previously called unconditionally inonRequestResponse
).