Skip to content

Performance issues to connect to Cypress Dashboard when behind a proxy #28423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Roemer opened this issue Nov 29, 2023 · 10 comments · Fixed by #31283
Closed

Performance issues to connect to Cypress Dashboard when behind a proxy #28423

Roemer opened this issue Nov 29, 2023 · 10 comments · Fixed by #31283
Assignees
Labels
prevent-stale mark an issue so it is ignored by stale[bot] type: performance 🏃‍♀️ Performance related

Comments

@Roemer
Copy link
Contributor

Roemer commented Nov 29, 2023

Current behavior

When running Cypress behind a corporate proxy, there is always a 1 minute overhead for each Cypress run when connecting to the Cypress Dashboard.
The problem seems to be the "preflight" request, which first tries to connect to api-proxy.cypress.io without the system-wide defined proxy and then after 1 minute, it tries api.cypress.io with the correct proxy which then responds immediately.

Desired behavior

No response

Test code to reproduce

This is a bit harder to reproduce easily. You need a setup where internet access is blocked unless a specific proxy is used, then define this proxy as http_proxy and https_proxy environment variable and run Cypress.

Cypress Version

13.5.0

Node version

v18.17.1

Operating System

Docker Container (Debian)

Debug Logs

cypress:server:cloud:api request to url: POST https://api-proxy.cypress.io/preflight with params: {"body":{"apiUrl":"https://api.cypress.io/","dependencies":{},"errors":[],"projectId":"xxx","ciBuildId":"rbl-test-05","testingType":"e2e","parallel":true},"headers":{"x-route-version":"1","x-cypress-request-attempt":0,"x-os-name":"linux","x-cypress-version":"13.5.0"}} and token: undefined +0ms

--------- Lots of process_profiler entries

cypress:server:cloud:api request to url: POST https://api.cypress.io/preflight with params: {"body":{"apiUrl":"https://api.cypress.io/","dependencies":{},"errors":[],"projectId":"xxx","ciBuildId":"rbl-test-05","testingType":"e2e","parallel":true},"headers":{"x-route-version":"1","x-cypress-request-attempt":0,"x-os-name":"linux","x-cypress-version":"13.5.0"}} and token: undefined +1m
cypress:network:agent addRequest called { isHttps: true, href: 'https://api.cypress.io/preflight' } +0ms
cypress:network:agent got family { family: undefined, href: 'https://api.cypress.io/preflight' } +1ms
cypress:network:agent Creating proxied socket for https://api.cypress.io/preflight through http://myproxy:3128 +3ms
cypress:network:connect successfully connected { opts: { port: 3128, host: 'myproxy', useTls: false, getDelayMsForRetry: [Function (anonymous)] }, iteration: 0 } +0ms
cypress:network:agent Proxy socket for https://api.cypress.io/preflight established +9ms
cypress:server:cloud:api response { apiUrl: 'https://api.cypress.io/', encrypt: false } +415ms

Other

No response

@Roemer
Copy link
Contributor Author

Roemer commented Nov 29, 2023

I created a MR which potentially fixes this issue here: #28340

@jennifer-shehane
Copy link
Member

We had some reports previously that running Cypress was slower when connected to the Cloud, but we were unable to reproduce it at the time. We'll take a look.

@Roemer
Copy link
Contributor Author

Roemer commented Jan 3, 2024

Any news here?
The issue is visible by using a local proxy (eg. Fiddler) and redirecting cypress to Fiddler. Then you see in Fiddlers log, that the first request (which is to api-proxy.cypress.io) is not visible in Fiddler (because it does not use the proxy at all) and then the second request (to api.cypress.io) is visible in Fiddler.

@Roemer
Copy link
Contributor Author

Roemer commented Feb 21, 2024

We still need to use a workaround to get an immediate (fail) response for the first request:

echo "127.0.0.1    api-proxy.cypress.io" >> /etc/hosts

It works but having a correct solution would still be the preferred way.

@jennifer-shehane
Copy link
Member

@Roemer Can you provide a repo that would reproduce the issue? For us to run?

@Roemer
Copy link
Contributor Author

Roemer commented Feb 27, 2024

A repo would not be enough, you need a specific network setup to reproduce it.
Basically, if you have a setup that blocks any internet access but allow connecting via a proxy, you would see that the first request to api-proxy.cypress.io is blocked and never reaches the proxy and then the second request to api.cypress.io would come thru the proxy and work.

@jennifer-shehane jennifer-shehane added the stage: needs investigating Someone from Cypress needs to look at this label Feb 27, 2024
@Roemer
Copy link
Contributor Author

Roemer commented Aug 15, 2024

This issue is still pending and the corresponding PR was closed. It is almost impossible to create a sample repo / test for the issue as this needs a specific networking setup (which is often used by corporates). If a dev would look at the (now closed PR), it is fairly obvious that is it currently broken.

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Feb 12, 2025
@mirobo
Copy link
Contributor

mirobo commented Feb 12, 2025

The situation is still the same. @Roemer provided a potential fix and the issue, as mentioned, is hard reproduce without the identical network setup. Could someone have a look at his PR and bring it to the finish line, @jennifer-shehane ? It would be very much appreciated so we can remove our workaround.

@cypress-app-bot cypress-app-bot removed the stale no activity on this issue for a long period label Feb 13, 2025
@jennifer-shehane jennifer-shehane added the prevent-stale mark an issue so it is ignored by stale[bot] label Feb 13, 2025
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 17, 2025

Released in 14.3.1.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v14.3.1, please open a new issue.

@cypress-bot cypress-bot bot removed the stage: needs investigating Someone from Cypress needs to look at this label Apr 17, 2025
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Apr 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
prevent-stale mark an issue so it is ignored by stale[bot] type: performance 🏃‍♀️ Performance related
Projects
None yet
5 participants