question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Delayed 304 responses when using proxy

See original GitHub issue

Current 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:closed
  • Created 4 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
cypress-bot[bot]commented, Jun 27, 2019

Released in 3.3.2.

0reactions
cypress-bot[bot]commented, Jun 19, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix the HTTP 304 Not Modified Status Code
The HTTP 304 not modified status code indicates a communication problem between a user's browser and a website's server.
Read more >
Solved: apache 304 error message
The 304 response MUST NOT contain a message-body, and thus is always terminated by the first empty line after the header fields.
Read more >
How to Solve Proxy Error Codes - The Ultimate Guide!
To keep using the proxy, you have to find a solution no matter what ... A server would respond with the “304 –...
Read more >
how to avoid a request with 304 status code returned in ...
If a client gets a 304 Not Modified, then it's the client's responsibility to display the resouce in question from its own cache....
Read more >
HTTP/1.1: Status Code Definitions
If a cache uses a received 304 response to update a cache entry, the cache MUST update the entry to reflect any new...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found