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 · 7 comments

Comments

3 participants
@testerez
Copy link

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

This comment has been minimized.

Copy link
Member

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.

@testerez

This comment has been minimized.

Copy link
Author

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

@flotwig

This comment has been minimized.

Copy link
Member

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.

@flotwig flotwig reopened this Jun 11, 2019

@testerez

This comment has been minimized.

Copy link
Author

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.

@flotwig

This comment has been minimized.

Copy link
Member

commented Jun 13, 2019

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

@cypress-bot

This comment has been minimized.

Copy link

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.

@cypress-bot

This comment has been minimized.

Copy link

commented Jun 27, 2019

Released in 3.3.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.