-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e8c01d8
fix: disable automatic request retries
flotwig ae7bda8
fix TLSv1
flotwig 97bad5e
update request_spec
flotwig 9c019a7
remove now invalid https_passthru_spec
flotwig b15d8b7
Explicitly set retryIntervals for visit/request
flotwig cf532de
Update network_error_handling_spec
flotwig be07807
Use same intervals as before
flotwig e5fa008
update request_spec
flotwig 008613f
loosen up network_error_handling_spec
flotwig 6292de3
fix: match pre-requests in reverse order
flotwig d627123
fix does not connect to the upstream proxy for the SNI server request
flotwig d618df3
rename onNext and onElse
flotwig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,15 +48,15 @@ const getOriginalHeaders = (req = {}) => { | |
} | ||
|
||
const getDelayForRetry = function (options = {}) { | ||
const { err, opts, delaysRemaining, retryIntervals, onNext, onElse } = options | ||
const { err, opts, delaysRemaining, retryIntervals, retryFn, onEnd } = options | ||
|
||
let delay = delaysRemaining.shift() | ||
|
||
if (!_.isNumber(delay)) { | ||
// no more delays, bailing | ||
debug('exhausted all attempts retrying request %o', merge(opts, { err })) | ||
|
||
return onElse() | ||
return onEnd() | ||
} | ||
|
||
// figure out which attempt we're on... | ||
|
@@ -76,7 +76,7 @@ const getDelayForRetry = function (options = {}) { | |
attempt, | ||
})) | ||
|
||
return onNext(delay, attempt) | ||
return retryFn({ delay, attempt }) | ||
} | ||
|
||
const hasRetriableStatusCodeFailure = (res, retryOnStatusCodeFailure) => { | ||
|
@@ -105,8 +105,8 @@ const maybeRetryOnNetworkFailure = function (err, options = {}) { | |
retryIntervals, | ||
delaysRemaining, | ||
retryOnNetworkFailure, | ||
onNext, | ||
onElse, | ||
retryFn, | ||
onEnd, | ||
} = options | ||
|
||
debug('received an error making http request %o', merge(opts, { err })) | ||
|
@@ -118,10 +118,15 @@ const maybeRetryOnNetworkFailure = function (err, options = {}) { | |
// https://github.com/cypress-io/cypress/pull/6705 | ||
debug('detected TLS version error, setting min version to TLSv1') | ||
opts.minVersion = 'TLSv1' | ||
|
||
if (retryIntervals.length === 0) { | ||
// normally, this request would not be retried, but we need to retry in order to support TLSv1 | ||
return retryFn({ delay: 0, attempt: 1 }) | ||
} | ||
} | ||
|
||
if (!isTlsVersionError && !isErrEmptyResponseError(err.originalErr || err) && !isRetriableError(err, retryOnNetworkFailure)) { | ||
return onElse() | ||
return onEnd() | ||
} | ||
|
||
// else see if we have more delays left... | ||
|
@@ -130,8 +135,8 @@ const maybeRetryOnNetworkFailure = function (err, options = {}) { | |
opts, | ||
retryIntervals, | ||
delaysRemaining, | ||
onNext, | ||
onElse, | ||
retryFn, | ||
onEnd, | ||
}) | ||
} | ||
|
||
|
@@ -143,8 +148,8 @@ const maybeRetryOnStatusCodeFailure = function (res, options = {}) { | |
retryIntervals, | ||
delaysRemaining, | ||
retryOnStatusCodeFailure, | ||
onNext, | ||
onElse, | ||
retryFn, | ||
onEnd, | ||
} = options | ||
|
||
debug('received status code & headers on request %o', { | ||
|
@@ -156,7 +161,7 @@ const maybeRetryOnStatusCodeFailure = function (res, options = {}) { | |
// is this a retryable status code failure? | ||
if (!hasRetriableStatusCodeFailure(res, retryOnStatusCodeFailure)) { | ||
// if not then we're done here | ||
return onElse() | ||
return onEnd() | ||
} | ||
|
||
// else see if we have more delays left... | ||
|
@@ -165,8 +170,8 @@ const maybeRetryOnStatusCodeFailure = function (res, options = {}) { | |
opts, | ||
retryIntervals, | ||
delaysRemaining, | ||
onNext, | ||
onElse, | ||
retryFn, | ||
onEnd, | ||
}) | ||
} | ||
|
||
|
@@ -201,7 +206,7 @@ const createRetryingRequestPromise = function (opts) { | |
retryOnStatusCodeFailure, | ||
} = opts | ||
|
||
const retry = (delay) => { | ||
const retry = ({ delay }) => { | ||
return Promise.delay(delay) | ||
.then(() => { | ||
return createRetryingRequestPromise(opts) | ||
|
@@ -216,8 +221,8 @@ const createRetryingRequestPromise = function (opts) { | |
retryIntervals, | ||
delaysRemaining, | ||
retryOnNetworkFailure, | ||
onNext: retry, | ||
onElse () { | ||
retryFn: retry, | ||
onEnd () { | ||
throw err | ||
}, | ||
}) | ||
|
@@ -229,8 +234,8 @@ const createRetryingRequestPromise = function (opts) { | |
retryIntervals, | ||
delaysRemaining, | ||
retryOnStatusCodeFailure, | ||
onNext: retry, | ||
onElse: _.constant(res), | ||
retryFn: retry, | ||
onEnd: _.constant(res), | ||
}) | ||
}) | ||
} | ||
|
@@ -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 }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 to destructuring refactor |
||
retryStream.emit('retry', { attempt, delay }) | ||
|
||
return setTimeout(tryStartStream, delay) | ||
|
@@ -337,8 +342,8 @@ const createRetryingRequestStream = function (opts = {}) { | |
retryIntervals, | ||
delaysRemaining, | ||
retryOnNetworkFailure, | ||
onNext: retry, | ||
onElse () { | ||
retryFn: retry, | ||
onEnd () { | ||
return emitError(err) | ||
}, | ||
}) | ||
|
@@ -360,8 +365,8 @@ const createRetryingRequestStream = function (opts = {}) { | |
delaysRemaining, | ||
retryIntervals, | ||
retryOnStatusCodeFailure, | ||
onNext: retry, | ||
onElse () { | ||
retryFn: retry, | ||
onEnd () { | ||
debug('successful response received', { requestId }) | ||
|
||
cleanup() | ||
|
@@ -414,7 +419,7 @@ const setDefaults = (opts) => { | |
.chain(opts) | ||
.defaults({ | ||
requestId: _.uniqueId('request'), | ||
retryIntervals: [0, 1000, 2000, 2000], | ||
retryIntervals: [], | ||
retryOnNetworkFailure: true, | ||
retryOnStatusCodeFailure: false, | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
'sresolve:url
andcy.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