79
await timeout(100 * attempt, token);
80
}
82
83
throw lastError;
85
86
private async _requestAttempt(options: IRequestOptions, token: CancellationToken): Promise<IRequestContext> {
88
throw new CancellationError();
89
}
91
>
const cancellation = new AbortController();
92
>
const cancellationListener = token.onCancellationRequested(() => cancellation.abort());
93
>
const signal = options.timeout
94
? AbortSignal.any([cancellation.signal, AbortSignal.timeout(options.timeout)])
96
>
97
>
try {
98
>
const response = await this._proxyResolver.fetch(options.url || '', {
99
>
method: options.type || 'GET',
100
>
headers: getRequestHeaders(options),
101
>
body: options.data,
102
>
signal,
103
>
cache: options.disableCache ? 'no-store' : undefined,
104
>
});
105
const stream = response.body
106
? responseBodyToStream(response.body, cancellation, cancellationListener)
107
: emptyResponseStream(cancellationListener);
109
>
res: {
110
>
statusCode: response.status,
111
>
headers: getResponseHeaders(response),
112
>
},
113
>
stream,
114
>
};
115
>
} catch (error) {
116
cancellationListener.dispose();
117
if (error instanceof Error && error.name === 'AbortError') {