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

vistit: Retry on ENOTFOUND errors #4424

Closed
testerez opened this issue Jun 10, 2019 · 9 comments
Closed

vistit: Retry on ENOTFOUND errors #4424

testerez opened this issue Jun 10, 2019 · 9 comments
Assignees

Comments

@testerez
Copy link

@testerez testerez commented Jun 10, 2019

Current behavior:

When using cy.vistit, if the DNS fails to resolve, we get: Error: getaddrinfo ENOTFOUND

Example:
Screen Shot 2019-06-10 at 10 37 09 AM

Desired behavior:

In our CI, the DNS is sometimes flaky. Unfortunately, we can't really fix that yet. So it would be nice if cypress offered a way to retry the visit command when we get this kind of errors.

Versions

cypress@3.3.1

@jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Jun 11, 2019

We recently implemented automatic retrying of cy.visit() in these situations in Cypress 3.3.0, so it has already retried and failed at this point.

Requests that go through cy.visit() or cy.request() are now automatically retried under the hood when the request fails. This more closely reflects Chrome’s default behavior on requests. Addresses #4013, #898 and #1013.

@flotwig We mention that we retried the cy.visit() in the CLI log when it fails on baseUrl, shouldn't we also mention we retried the cy.visit() in the Command Log here?

You can implement rerunning the commands/tests when they fail using the cypress-plugin-retires mentioned here. #1313 (comment)

I'm afraid this is all we can recommend in this situation.

Loading

@testerez
Copy link
Author

@testerez testerez commented Jun 11, 2019

From a quick test, it does not look like Cypress retries in this specific situation. You can easily reproduce with:

it('will fail instantly with ENOTFOUND', () => {
  cy.visit('http://foo.localhost');
});

When I try this, Cypress fails instantly (0.21s):

Screen Shot 2019-06-11 at 6 49 26 AM

Loading

@flotwig
Copy link
Member

@flotwig flotwig commented Jun 11, 2019

We initially left out retrying on ENOTFOUND because we thought this scenario didn't exist in the wild (flaky DNS???), but it can definitely be added.

Loading

@flotwig flotwig reopened this Jun 11, 2019
@testerez
Copy link
Author

@testerez testerez commented Jun 11, 2019

Cool thank you @flotwig! To be honest I'm not entirely sure why we have this issue. But it happens when our CI deploys an ephemeral to test against. We do wait until the deployment is ready before starting the Cypress tests but sometimes we still get this intermittent ENOTFOUND error. Maybe the record is not yet propagated everywhere. Anyway, if Cypress could just retry when we get this error it would be a quick fix for us.

Loading

@flotwig
Copy link
Member

@flotwig flotwig commented Jun 13, 2019

Actually found another instance of this DNS flakiness, so I guess it's not as rare as we thought: #1755

Loading

@cypress-bot
Copy link

@cypress-bot cypress-bot bot commented Jun 14, 2019

The code for this is done in cypress-io/cypress#4459, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

Loading

@cypress-bot
Copy link

@cypress-bot cypress-bot bot commented Jun 27, 2019

Released in 3.3.2.

Loading

@pardeeprj90
Copy link

@pardeeprj90 pardeeprj90 commented Nov 27, 2020

Error: getaddrinfo ENOTFOUND vfolpuat.ctdi.com
image

still, issue exists, the same code was working previously fine.

Loading

@jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Dec 8, 2020

This issue will be closed to further comment as the exact issue here was resolved and tested.

@pardeeprj90 If you're experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix.

Loading

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants