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
207207 // We need to hardcode them here until we're able to reuse the SDK
208208 // from within this hook
209209
210+ const allowedRetries = 3 ;
210211 const retryConfig = {
211212 strategy : "backoff" ,
212213 backoff : {
@@ -219,13 +220,19 @@ export class SplitPdfHook
219220
220221 const retryCodes = [ "502" , "503" , "504" ] ;
221222
223+
222224 this . partitionRequests [ operationID ] = async . parallelLimit (
223225 requests . map ( ( req , pageIndex ) => async ( ) => {
224226 const pageNumber = pageIndex + startingPageNumber ;
227+ let retryCount = 0 ;
225228 try {
226229 const response = await retry (
227230 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 ( ) ) ;
229236 } ,
230237 { config : retryConfig , statusCodes : retryCodes }
231238 ) ;
Original file line number Diff line number Diff line change @@ -32,8 +32,7 @@ export class HTTPClientExtension extends HTTPClient {
3232 }
3333
3434 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/" ) {
3736 return new Response ( '{}' , {
3837 headers : [
3938 [ "fake-response" , "fake-response" ]
@@ -42,6 +41,6 @@ export class HTTPClientExtension extends HTTPClient {
4241 statusText : 'OK_NO_OP'
4342 } ) ;
4443 }
45- return super . request ( clone ) ;
44+ return super . request ( request ) ;
4645 }
4746}
You can’t perform that action at this time.
0 commit comments