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

fix: disable automatic request retries #19161

Merged
merged 12 commits into from Dec 8, 2021

Conversation

flotwig
Copy link
Contributor

@flotwig flotwig commented Nov 30, 2021

User facing changelog

  • Removed automatic retries for failed HTTP requests through the proxy. This fixes an issue where failed requests could be re-sent too many times in some conditions. This change could increase the number of failed requests that your app sees.
  • Reduced the occurrence of an issue where logs for fetch and xhr requests could be associated with the wrong request.

Additional details

  • This disables the proxy layer's automatic retries.
  • Automatic retries are still used for cy.visit's resolve:url and cy.request, since those are not retriable by the browser.
  • Fully removing automatic retries is a breaking change b/c we expose retryOnNetworkFailure and retryOnStatusCodeFailure as opts on cy.request, cy.visit
  • Has the potential to

How has the user experience changed?

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?
  • [na] Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 30, 2021

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Nov 30, 2021



Test summary

18709 0 202 0Flakiness 0


Run details

Project cypress
Status Passed
Commit d618df3
Started Dec 8, 2021 3:46 PM
Ended Dec 8, 2021 3:57 PM
Duration 11:21 💡
OS Linux Debian - 10.10
Browser Multiple

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@flotwig flotwig marked this pull request as ready for review December 7, 2021 16:04

if (retryIntervals.length === 0) {
// normally, this request would not be retried, but we need to retry in order to support TLSv1
return onNext(0, 1)
Copy link
Member

Choose a reason for hiding this comment

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

what does onNext(0, 1) do? Is there a way we could make the code more descriptive?

Copy link
Contributor Author

@flotwig flotwig Dec 8, 2021

Choose a reason for hiding this comment

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

const retry = function (delay, attempt) {
retryStream.emit('retry', { attempt, delay })
return setTimeout(tryStartStream, delay)
}

So this runs a single retry instantly.

Is there a way we could make the code more descriptive?

So many ways. 😄 I started refactoring this file and it became a much bigger task, so I decided to keep this PR to the bare minimum changes. For now I pushed a commit to clean up onNext/onElse specifically: d618df3

@@ -28,6 +28,7 @@ const REQUEST_DEFAULTS = {
timeout: null,
followRedirect: true,
failOnStatusCode: true,
retryIntervals: [0, 100, 200, 200],
Copy link
Member

Choose a reason for hiding this comment

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

Why are we adding retry intervals here and above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously this would inherit from the defaults in server/lib/request, but now it has to set its own.

Automatic retries are still used for cy.visit's resolve:url and cy.request, since those are not retriable by the browser. Fully removing automatic retries is a breaking change b/c we expose retryOnNetworkFailure and retryOnStatusCodeFailure as opts on cy.request, cy.visit

@flotwig flotwig requested a review from mjhenkes December 8, 2021 15:40
@flotwig flotwig force-pushed the issue-19043-remove-request-retry branch from 5df0b86 to 2901f91 Compare December 8, 2021 15:40
@flotwig flotwig force-pushed the issue-19043-remove-request-retry branch from 2901f91 to d618df3 Compare December 8, 2021 15:41
@@ -281,7 +286,7 @@ const createRetryingRequestStream = function (opts = {}) {
const reqStream = r(opts)
let didReceiveResponse = false

const retry = function (delay, attempt) {
const retry = function ({ delay, attempt }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 to destructuring refactor

@flotwig flotwig merged commit 65cf6e8 into develop Dec 8, 2021
@flotwig flotwig deleted the issue-19043-remove-request-retry branch December 8, 2021 22:27
tgriesser added a commit that referenced this pull request Dec 15, 2021
* develop:
  chore(deps): update dependency ssri to 6.0.2 [security] (#19351)
  chore: Fix server unit tests running on mac by using actual tmp dir (#19350)
  fix: Add more precise types to Cypress.Commands (#19003)
  fix: Do not screenshot or trigger the failed event when tests are skipped (#19331)
  fix (#19262)
  fix: throw when writing to 'read only' properties of `config` (#18896)
  fix: close chrome when closing electron (#19322)
  fix: disable automatic request retries (#19161)
  chore: refactor cy funcs (#19080)
  chore(deps): update dependency @ffmpeg-installer/ffmpeg to v1.1.0 🌟 (#19300)
tgriesser added a commit that referenced this pull request Dec 16, 2021
…cycle

* 10.0-release:
  build: remove syncRemoteGraphQL from codegen
  chore: fix incorrect type from merge
  build: allow work with local dashboard (#19376)
  chore: Test example recipes against chrome (#19362)
  test(unify): Settings e2e tests (#19324)
  chore(deps): update dependency ssri to 6.0.2 [security] (#19351)
  fix: spec from story generation, add deps for install (#19352)
  chore: Fix server unit tests running on mac by using actual tmp dir (#19350)
  fix: Add more precise types to Cypress.Commands (#19003)
  fix: Do not screenshot or trigger the failed event when tests are skipped (#19331)
  fix (#19262)
  fix: throw when writing to 'read only' properties of `config` (#18896)
  fix: close chrome when closing electron (#19322)
  fix: disable automatic request retries (#19161)
  chore: refactor cy funcs (#19080)
  chore(deps): update dependency @ffmpeg-installer/ffmpeg to v1.1.0 🌟 (#19300)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed requests retry 25 times
3 participants