Feat add exp 429 retry - #46
Conversation
@testplane/devtools
eslint-plugin-wdio
@wdio/allure-reporter
@wdio/appium-service
@wdio/browser-runner
@wdio/browserstack-service
@wdio/cli
@wdio/concise-reporter
@testplane/wdio-config
@wdio/cucumber-framework
@wdio/dot-reporter
@wdio/firefox-profile-service
@wdio/globals
@wdio/jasmine-framework
@wdio/json-reporter
@wdio/junit-reporter
@wdio/lighthouse-service
@wdio/local-runner
@testplane/wdio-logger
@wdio/mocha-framework
@testplane/wdio-protocols
@testplane/wdio-repl
@wdio/reporter
@wdio/runner
@wdio/sauce-service
@wdio/shared-store-service
@wdio/smoke-test-cjs-service
@wdio/smoke-test-reporter
@wdio/smoke-test-service
@wdio/spec-reporter
@wdio/static-server-service
@wdio/sumologic-reporter
@wdio/testingbot-service
@testplane/wdio-types
@testplane/wdio-utils
@wdio/webdriver-mock-service
@testplane/webdriver
@testplane/webdriverio
commit: |
b7cad1d to
1389b4f
Compare
| * Base delay in ms for exponential backoff on 429 responses during session creation. | ||
| * If set, retries use exponential backoff instead of immediate retry. | ||
| */ | ||
| exp429RetryBaseDelay?: number |
There was a problem hiding this comment.
I suggest removing the option and leaving only the constant value. In my opinion, there is no reason for a new option.
| log.warn(msg) | ||
| log.info(`Retrying ${retryCount}/${totalRetryCount}`) | ||
|
|
||
| const exp429RetryBaseDelay = fullRequestOptions.exp429RetryBaseDelay |
There was a problem hiding this comment.
I suggest changing the name of this variable it's too complicated
| log.info(`Retrying ${retryCount}/${totalRetryCount}`) | ||
|
|
||
| const exp429RetryBaseDelay = fullRequestOptions.exp429RetryBaseDelay | ||
| if (exp429RetryBaseDelay && !(response instanceof Error) && response.statusCode === 429) { |
There was a problem hiding this comment.
why are we here retraying absolutely all requests, not just for creating a session?
| const exp429RetryBaseDelay = fullRequestOptions.exp429RetryBaseDelay | ||
| if (exp429RetryBaseDelay && !(response instanceof Error) && response.statusCode === 429) { | ||
| const delay = Math.round(exp429RetryBaseDelay * 2 ** (retryCount - 1) + Math.random() * 100) | ||
| log.warn(`Session creation failed with 429, retrying in ${delay}ms`) |
There was a problem hiding this comment.
Are you sure we need a warning here, not a debug log?
|
|
||
| const exp429RetryBaseDelay = fullRequestOptions.exp429RetryBaseDelay | ||
| if (exp429RetryBaseDelay && !(response instanceof Error) && response.statusCode === 429) { | ||
| const delay = Math.round(exp429RetryBaseDelay * 2 ** (retryCount - 1) + Math.random() * 100) |
There was a problem hiding this comment.
why is the jitter so low? Only 100ms
| const delay = Math.round(exp429RetryBaseDelay * 2 ** (retryCount - 1) + Math.random() * 100) | ||
| log.warn(`Session creation failed with 429, retrying in ${delay}ms`) | ||
| return new Promise(resolve => setTimeout(resolve, delay)).then( | ||
| () => this._request(fullRequestOptions, transformResponse, customWdRequestAgent, totalRetryCount, retryCount) |
There was a problem hiding this comment.
why not just delete this call and use the call of this._request below?
There was a problem hiding this comment.
I used here timeout and it was more easy to implement
There was a problem hiding this comment.
I used here timeout and it was more easy to implement
I don't understand why is code duplication easier to implement?
In my opinion, it is more correct to call the method once, especially if it has 4 parameters.
| return new Promise(resolve => setTimeout(resolve, delay)).then( | ||
| () => this._request(fullRequestOptions, transformResponse, customWdRequestAgent, totalRetryCount, retryCount) | ||
| ) | ||
| } |
There was a problem hiding this comment.
what if tomorrow we let the user manage connectionRetryCount option? And he set value 10. How much we should wait? I'm saying that we need some kind of maximum limit.
There was a problem hiding this comment.
We set this on testplane side, and maybe we have to set max limit there and do it when we provide it to config for users?
There was a problem hiding this comment.
usually, when implementing retires logic, jitter and the maximum limit are always used
1389b4f to
d642e9a
Compare
When a WebDriver grid responds with 429 (Too Many Requests) during, retries now use exponential backoff instead of hammering the server immediately.
Retry delays follow the formula
5000 × 2^attempt + jitter(0..1000ms), giving approximately 5s → 10s → 20s between attempts.The number of retries is controlled by the existing
connectionRetryCountoption.The backoff applies only to all requests which get 429.