From fdf48617528ba0a6bb9b2ce322c76b1cebb0f90e Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Wed, 19 Jun 2024 16:09:31 -0700 Subject: [PATCH] Set to 0 by default --- docs/src/api/class-requestoptions.md | 2 +- docs/src/api/params.md | 2 +- packages/playwright-core/src/server/fetch.ts | 2 +- packages/playwright-core/types/types.d.ts | 12 ++++++------ tests/library/browsercontext-fetch.spec.ts | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/src/api/class-requestoptions.md b/docs/src/api/class-requestoptions.md index 2ad31f8dbb..401e13d944 100644 --- a/docs/src/api/class-requestoptions.md +++ b/docs/src/api/class-requestoptions.md @@ -134,7 +134,7 @@ Defaults to `20`. Pass `0` to not follow redirects. * since: v1.46 - `maxRetries` <[int]> -Maximum number of times socket errors should be retried. Currently only `ECONNRESET` error is retried. An error will be thrown if the limit is exceeded. Defaults to `5`. Pass `0` to disable retries. +Maximum number of times socket errors should be retried. Currently only `ECONNRESET` error is retried. An error will be thrown if the limit is exceeded. Defaults to `0` - no retries. ## method: RequestOptions.setMethod * since: v1.18 diff --git a/docs/src/api/params.md b/docs/src/api/params.md index b95372e2cf..253ca3a1fd 100644 --- a/docs/src/api/params.md +++ b/docs/src/api/params.md @@ -462,7 +462,7 @@ Defaults to `20`. Pass `0` to not follow redirects. * langs: js, python, csharp - `maxRetries` <[int]> -Maximum number of times socket errors should be retried. Currently only `ECONNRESET` error is retried. An error will be thrown if the limit is exceeded. Defaults to `5`. Pass `0` to disable retries. +Maximum number of times socket errors should be retried. Currently only `ECONNRESET` error is retried. An error will be thrown if the limit is exceeded. Defaults to `0` - no retries. ## evaluate-expression - `expression` <[string]> diff --git a/packages/playwright-core/src/server/fetch.ts b/packages/playwright-core/src/server/fetch.ts index 7f65af8799..c02781f748 100644 --- a/packages/playwright-core/src/server/fetch.ts +++ b/packages/playwright-core/src/server/fetch.ts @@ -248,7 +248,7 @@ export abstract class APIRequestContext extends SdkObject { } private async _sendRequestWithRetries(progress: Progress, url: URL, options: SendRequestOptions, postData?: Buffer, maxRetries?: number): Promise & { body: Buffer }>{ - maxRetries ??= 5; + maxRetries ??= 0; let backoff = 250; for (let i = 0; i <= maxRetries; i++) { try { diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts index a7057a8d84..67e92a917a 100644 --- a/packages/playwright-core/types/types.d.ts +++ b/packages/playwright-core/types/types.d.ts @@ -15965,7 +15965,7 @@ export interface APIRequestContext { /** * Maximum number of times socket errors should be retried. Currently only `ECONNRESET` error is retried. An error - * will be thrown if the limit is exceeded. Defaults to `5`. Pass `0` to disable retries. + * will be thrown if the limit is exceeded. Defaults to `0` - no retries. */ maxRetries?: number; @@ -16071,7 +16071,7 @@ export interface APIRequestContext { /** * Maximum number of times socket errors should be retried. Currently only `ECONNRESET` error is retried. An error - * will be thrown if the limit is exceeded. Defaults to `5`. Pass `0` to disable retries. + * will be thrown if the limit is exceeded. Defaults to `0` - no retries. */ maxRetries?: number; @@ -16157,7 +16157,7 @@ export interface APIRequestContext { /** * Maximum number of times socket errors should be retried. Currently only `ECONNRESET` error is retried. An error - * will be thrown if the limit is exceeded. Defaults to `5`. Pass `0` to disable retries. + * will be thrown if the limit is exceeded. Defaults to `0` - no retries. */ maxRetries?: number; @@ -16243,7 +16243,7 @@ export interface APIRequestContext { /** * Maximum number of times socket errors should be retried. Currently only `ECONNRESET` error is retried. An error - * will be thrown if the limit is exceeded. Defaults to `5`. Pass `0` to disable retries. + * will be thrown if the limit is exceeded. Defaults to `0` - no retries. */ maxRetries?: number; @@ -16371,7 +16371,7 @@ export interface APIRequestContext { /** * Maximum number of times socket errors should be retried. Currently only `ECONNRESET` error is retried. An error - * will be thrown if the limit is exceeded. Defaults to `5`. Pass `0` to disable retries. + * will be thrown if the limit is exceeded. Defaults to `0` - no retries. */ maxRetries?: number; @@ -16457,7 +16457,7 @@ export interface APIRequestContext { /** * Maximum number of times socket errors should be retried. Currently only `ECONNRESET` error is retried. An error - * will be thrown if the limit is exceeded. Defaults to `5`. Pass `0` to disable retries. + * will be thrown if the limit is exceeded. Defaults to `0` - no retries. */ maxRetries?: number; diff --git a/tests/library/browsercontext-fetch.spec.ts b/tests/library/browsercontext-fetch.spec.ts index 2551c4fc21..a8aaeb389f 100644 --- a/tests/library/browsercontext-fetch.spec.ts +++ b/tests/library/browsercontext-fetch.spec.ts @@ -59,7 +59,7 @@ it('should throw on network error', async ({ context, server }) => { server.setRoute('/test', (req, res) => { req.socket.destroy(); }); - const error = await context.request.get(server.PREFIX + '/test', { maxRetries: 0 }).catch(e => e); + const error = await context.request.get(server.PREFIX + '/test').catch(e => e); expect(error.message).toContain('apiRequestContext.get: socket hang up'); }); @@ -68,7 +68,7 @@ it('should throw on network error after redirect', async ({ context, server }) = server.setRoute('/test', (req, res) => { req.socket.destroy(); }); - const error = await context.request.get(server.PREFIX + '/redirect', { maxRetries: 0 }).catch(e => e); + const error = await context.request.get(server.PREFIX + '/redirect').catch(e => e); expect(error.message).toContain('apiRequestContext.get: socket hang up'); });