Set to 0 by default
This commit is contained in:
parent
a732588a16
commit
fdf4861752
|
|
@ -134,7 +134,7 @@ Defaults to `20`. Pass `0` to not follow redirects.
|
||||||
* since: v1.46
|
* since: v1.46
|
||||||
- `maxRetries` <[int]>
|
- `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
|
## method: RequestOptions.setMethod
|
||||||
* since: v1.18
|
* since: v1.18
|
||||||
|
|
|
||||||
|
|
@ -462,7 +462,7 @@ Defaults to `20`. Pass `0` to not follow redirects.
|
||||||
* langs: js, python, csharp
|
* langs: js, python, csharp
|
||||||
- `maxRetries` <[int]>
|
- `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
|
## evaluate-expression
|
||||||
- `expression` <[string]>
|
- `expression` <[string]>
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@ export abstract class APIRequestContext extends SdkObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _sendRequestWithRetries(progress: Progress, url: URL, options: SendRequestOptions, postData?: Buffer, maxRetries?: number): Promise<Omit<channels.APIResponse, 'fetchUid'> & { body: Buffer }>{
|
private async _sendRequestWithRetries(progress: Progress, url: URL, options: SendRequestOptions, postData?: Buffer, maxRetries?: number): Promise<Omit<channels.APIResponse, 'fetchUid'> & { body: Buffer }>{
|
||||||
maxRetries ??= 5;
|
maxRetries ??= 0;
|
||||||
let backoff = 250;
|
let backoff = 250;
|
||||||
for (let i = 0; i <= maxRetries; i++) {
|
for (let i = 0; i <= maxRetries; i++) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
12
packages/playwright-core/types/types.d.ts
vendored
12
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -15965,7 +15965,7 @@ export interface APIRequestContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum number of times socket errors should be retried. Currently only `ECONNRESET` error is retried. An error
|
* 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;
|
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
|
* 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;
|
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
|
* 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;
|
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
|
* 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;
|
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
|
* 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;
|
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
|
* 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;
|
maxRetries?: number;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ it('should throw on network error', async ({ context, server }) => {
|
||||||
server.setRoute('/test', (req, res) => {
|
server.setRoute('/test', (req, res) => {
|
||||||
req.socket.destroy();
|
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');
|
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) => {
|
server.setRoute('/test', (req, res) => {
|
||||||
req.socket.destroy();
|
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');
|
expect(error.message).toContain('apiRequestContext.get: socket hang up');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue