Skip to content
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

Retry certain requests on failure #4015

Merged
merged 117 commits into from
May 15, 2019
Merged

Retry certain requests on failure #4015

merged 117 commits into from
May 15, 2019

Conversation

flotwig
Copy link
Contributor

@flotwig flotwig commented Apr 22, 2019

Closes #4013
Closes #898
Closes #1013
Closes #4232

  • Retry cy.visit(), cy.request(), and all requests that go through Cypress under the hood
    • If options.retryOnNetworkFailure is true (default) or it's a Cypress proxy request, ECONNREFUSED, ECONNRESET, EPIPE, EHOSTUNREACH, and EAI_AGAIN errors will be retried
    • If options.retryOnStatusCodeFailure is true, requests will be retried on non-successful status codes
    • Retries will happen 4 times at increasing intervals: 0s, 1s, 2s, 2s
    • ECONNREFUSED retries and proxied retries happen at shorter intervals: 0s, 100ms, 200ms, 200ms
    • Proxied request bodies will be buffered in memory as they are streamed in so that we can re-send them in the event of a network error
  • Set { timeout: null } on proxied requests so the only timeout is the eventual OS timeout, since Chrome won't timeout
  • Retry https-proxy connections in proxied mode and in direct mode using same rules
  • Retry the baseUrl check in run mode at 0s, 1s, 2s, 2s intervals, then fail if it is unsuccessful
  • Update documentation: Document changes to network retries cypress-documentation#1648

@flotwig
Copy link
Contributor Author

flotwig commented Apr 25, 2019

New baseurl check output in run mode:

Cypress could not verify that the server set as your `baseUrl` is running: http://never-gonna-exist.invalid

Your tests likely make requests to this `baseUrl` and these tests will fail if you don't boot your server.

We will retry 3 more times in 1 second...

Cypress could not verify that the server set as your `baseUrl` is running: http://never-gonna-exist.invalid

Your tests likely make requests to this `baseUrl` and these tests will fail if you don't boot your server.

We will retry 2 more times in 2 seconds...

Cypress could not verify that the server set as your `baseUrl` is running: http://never-gonna-exist.invalid

Your tests likely make requests to this `baseUrl` and these tests will fail if you don't boot your server.

We will retry 1 more time in 2 seconds...
Cypress could not verify that the server set as your `baseUrl` is running:

  > http://never-gonna-exist.invalid

Your tests likely make requests to this `baseUrl` and these tests will fail if you don't boot your server.

Please start this server and then run Cypress again.

Copy link
Member

@brian-mann brian-mann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • didn't get a chance to clean up some of the retrying proxy stuff in the packages/agent but otherwise LGTM!

@YOU54F
Copy link
Contributor

YOU54F commented May 15, 2019

Hey @flotwig / @brian-mann , I just pulled this commit into my fork whilst testing microsoft edge and I can't load any browsers now in gui or cli mode, I get the error in the terminal output below.

Just removed pulling master into my fork (this pr and it has resolved it for all browsers, just a friendly fyi 👍

I am running a mbp 2018 with mojave 10.14.4

➜  cypress git:(feat/msEdge) ✗ npm run start
Alias tip: npmR start

> [email protected] prestart /Users/you54f/dev/saftest/githubrepos/forks/cypress
> npm run check-deps-pre


> [email protected] check-deps-pre /Users/you54f/dev/saftest/githubrepos/forks/cypress
> node ./scripts/check-deps.js --verbose --prescript


> [email protected] start /Users/you54f/dev/saftest/githubrepos/forks/cypress
> node ./cli/bin/cypress open --dev --global

GET /__/ 200 23.792 ms - -
TypeError: connect.createRetryingSocket is not a function
    at Server._makeConnection (/Users/you54f/dev/saftest/githubrepos/forks/cypress/packages/https-proxy/lib/server.coffee:144:20)
    at Server._makeDirectConnection (/Users/you54f/dev/saftest/githubrepos/forks/cypress/packages/https-proxy/lib/server.coffee:103:6)
    at Server._onFirstHeadBytes (/Users/you54f/dev/saftest/githubrepos/forks/cypress/packages/https-proxy/lib/server.coffee:71:17)
    at Socket.<anonymous> (/Users/you54f/dev/saftest/githubrepos/forks/cypress/packages/https-proxy/lib/server.coffee:62:8)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:594:20)

@flotwig
Copy link
Contributor Author

flotwig commented May 15, 2019

@YOU54F try deleting all of the .js files from packages/network/lib, you have an old version of a TS file transpiled

@YOU54F
Copy link
Contributor

YOU54F commented May 16, 2019

Spot on @flotwig , sorted it, thank you for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants