Delayed 304 responses when using proxy
See original GitHub issueCurrent behaviour:
When a page loads resources, and the resources have been loaded before, the web server returns a 304 response. When running Cypress without proxy, this works fine. When running Cypress with proxy, there is a 5 second delay before the response reaches the browser.
Desired behavior:
There should be no additional delay on 304 responses with a proxy.
Steps to reproduce: (app code and test code)
I have created a minimal demo for the issue. Please see: https://github.com/bjowes/delayed-response-demo
The README contains instruction on using the demo.
In this simplistic case, the tests still pass. In my real scenario I am testing an Angular app with many more resources. The tests fail nearly every time due to timeout caused by delayed 304 responses.
Versions
Tested with Cypress 3.3.1 on Windows 10 and OS X 10.14.4. Browser: Chrome v74. Also tried in headless mode with Electron 61. I haven’t double checked but I believe the behaviour has been present at least since Cypress 3.1.0.
Comment
Since the proxy I use is made by me (and based on the node-http-mitm-proxy
library), I realise that the error may lie in the proxy itself. However, I have verified that using Chrome with my proxy but without Cypress works just fine.
The only thing the node-http-mitm-proxy
does to the traffic is setting transfer-encoding
to chunked
and removing the content-length
header (if any). I have observed that if I remove this in the case of 304 response (which has no content) it works fine. Hence I presume there is some issue related to chunked
encoding consisting of only an empty chunk.
Personally I can live with my workaround but I believe that it is not an unusual approach by proxies to always set transfer-encoding
on responses to chunked
, especially those that allow modification of the content.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (9 by maintainers)
Top GitHub Comments
Released in
3.3.2
.The code for this is done in cypress-io/cypress#4358, but has yet to be released. We’ll update this issue and reference the changelog when it’s released.