Skip to content

Commit 51a54ff

Browse files
authored
increase timeout to 60 minutes (#117)
A customer reported that large PDFs are still failing, even after the updated retry logic for the occasional 502/503s. The job client previously had an incorrect limit of 10 minutes for maximum execution time. This change increase the total client execution time to 60 minutes. ### Testing Ran custom integration tests with 2500 page PDFs running with the following settings: ``` const requestParams: PartitionParameters = { files: file, splitPdfPage: true, strategy: Strategy.HiRes, splitPdfAllowFailed: false, splitPdfConcurrencyLevel: 15 }; const res: PartitionResponse = await client.general.partition({ partitionParameters: { ...requestParams }, }); ```
1 parent e830b7b commit 51a54ff

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/hooks/custom/SplitPdfHook.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ export class SplitPdfHook
164164
splitSize,
165165
)
166166

167+
const oneSecond = 1000;
168+
const oneMinute = 1000 * 60;
169+
const sixtyMinutes = oneMinute * 60;
170+
167171
const headers = prepareRequestHeaders(request);
168172

169173
const requests: Request[] = [];
@@ -185,11 +189,10 @@ export class SplitPdfHook
185189
file.name,
186190
firstPageNumber
187191
);
188-
const timeoutInMs = 60 * 10 * 1000;
189192
const req = new Request(requestClone, {
190193
headers,
191194
body,
192-
signal: AbortSignal.timeout(timeoutInMs)
195+
signal: AbortSignal.timeout(sixtyMinutes)
193196
});
194197
requests.push(req);
195198
setIndex+=1;
@@ -203,15 +206,14 @@ export class SplitPdfHook
203206
// These are the retry values from our api spec
204207
// We need to hardcode them here until we're able to reuse the SDK
205208
// from within this hook
206-
const oneSecond = 1000;
207-
const oneMinute = 1000 * 60;
209+
208210
const retryConfig = {
209211
strategy: "backoff",
210212
backoff: {
211213
initialInterval: oneSecond * 3,
212214
maxInterval: oneMinute * 12,
213215
exponent: 1.88,
214-
maxElapsedTime: oneMinute * 30,
216+
maxElapsedTime: sixtyMinutes,
215217
},
216218
} as RetryConfig;
217219

@@ -223,7 +225,7 @@ export class SplitPdfHook
223225
try {
224226
const response = await retry(
225227
async () => {
226-
return await this.client!.request(req.clone());
228+
return await this.client!.request(req);
227229
},
228230
{ config: retryConfig, statusCodes: retryCodes }
229231
);

src/hooks/custom/common.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export class HTTPClientExtension extends HTTPClient {
3232
}
3333

3434
override async request(request: Request): Promise<Response> {
35-
if (request.url === "https://no-op/") {
35+
const clone = request.clone();
36+
if (clone.url === "https://no-op/") {
3637
return new Response('{}', {
3738
headers: [
3839
["fake-response", "fake-response"]
@@ -41,6 +42,6 @@ export class HTTPClientExtension extends HTTPClient {
4142
statusText: 'OK_NO_OP'
4243
});
4344
}
44-
return super.request(request);
45+
return super.request(clone);
4546
}
4647
}

0 commit comments

Comments
 (0)