File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,7 @@ export class SplitPdfHook
207
207
// We need to hardcode them here until we're able to reuse the SDK
208
208
// from within this hook
209
209
210
+ const allowedRetries = 3 ;
210
211
const retryConfig = {
211
212
strategy : "backoff" ,
212
213
backoff : {
@@ -219,13 +220,19 @@ export class SplitPdfHook
219
220
220
221
const retryCodes = [ "502" , "503" , "504" ] ;
221
222
223
+
222
224
this . partitionRequests [ operationID ] = async . parallelLimit (
223
225
requests . map ( ( req , pageIndex ) => async ( ) => {
224
226
const pageNumber = pageIndex + startingPageNumber ;
227
+ let retryCount = 0 ;
225
228
try {
226
229
const response = await retry (
227
230
async ( ) => {
228
- return await this . client ! . request ( req ) ;
231
+ retryCount ++ ;
232
+ if ( retryCount > allowedRetries ) {
233
+ throw new Error ( `Number of retries exceeded for page ${ pageNumber } ` ) ;
234
+ }
235
+ return await this . client ! . request ( req . clone ( ) ) ;
229
236
} ,
230
237
{ config : retryConfig , statusCodes : retryCodes }
231
238
) ;
Original file line number Diff line number Diff line change @@ -32,8 +32,7 @@ export class HTTPClientExtension extends HTTPClient {
32
32
}
33
33
34
34
override async request ( request : Request ) : Promise < Response > {
35
- const clone = request . clone ( ) ;
36
- if ( clone . url === "https://no-op/" ) {
35
+ if ( request . url === "https://no-op/" ) {
37
36
return new Response ( '{}' , {
38
37
headers : [
39
38
[ "fake-response" , "fake-response" ]
@@ -42,6 +41,6 @@ export class HTTPClientExtension extends HTTPClient {
42
41
statusText : 'OK_NO_OP'
43
42
} ) ;
44
43
}
45
- return super . request ( clone ) ;
44
+ return super . request ( request ) ;
46
45
}
47
46
}
You can’t perform that action at this time.
0 commit comments