From f45cf659215e97f921add54f6de44cbc171ab303 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 29 Jul 2024 14:39:30 +0200 Subject: [PATCH] chore: add maxRetries to APIRequestContext.delete (#31893) --- docs/src/api/class-apirequestcontext.md | 3 +++ packages/playwright-core/types/types.d.ts | 6 ++++++ tests/library/browsercontext-fetch.spec.ts | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/src/api/class-apirequestcontext.md b/docs/src/api/class-apirequestcontext.md index dab99bec2be6c..08cc8d993faee 100644 --- a/docs/src/api/class-apirequestcontext.md +++ b/docs/src/api/class-apirequestcontext.md @@ -180,6 +180,9 @@ context cookies from the response. The method will automatically follow redirect ### option: APIRequestContext.delete.maxRedirects = %%-js-python-csharp-fetch-option-maxredirects-%% * since: v1.26 +### option: APIRequestContext.delete.maxRetries = %%-js-python-csharp-fetch-option-maxretries-%% +* since: v1.46 + ## async method: APIRequestContext.dispose * since: v1.16 diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts index 47e263cdb63f2..7026f64555b39 100644 --- a/packages/playwright-core/types/types.d.ts +++ b/packages/playwright-core/types/types.d.ts @@ -15807,6 +15807,12 @@ export interface APIRequestContext { */ maxRedirects?: number; + /** + * Maximum number of times network errors should be retried. Currently only `ECONNRESET` error is retried. Does not + * retry based on HTTP response codes. An error will be thrown if the limit is exceeded. Defaults to `0` - no retries. + */ + maxRetries?: number; + /** * Provides an object that will be serialized as html form using `multipart/form-data` encoding and sent as this * request body. If this parameter is specified `content-type` header will be set to `multipart/form-data` unless diff --git a/tests/library/browsercontext-fetch.spec.ts b/tests/library/browsercontext-fetch.spec.ts index f8c0327c7df92..bffb1b82f1139 100644 --- a/tests/library/browsercontext-fetch.spec.ts +++ b/tests/library/browsercontext-fetch.spec.ts @@ -1288,7 +1288,7 @@ it('should not work after context dispose', async ({ context, server }) => { expect(await context.request.get(server.EMPTY_PAGE).catch(e => e.message)).toContain('Test ended.'); }); -it('should retrty ECONNRESET', { +it('should retry on ECONNRESET', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/30978' } }, async ({ context, server }) => { let requestCount = 0;