Skip to content

increase timeout to 60 minutes #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/hooks/custom/SplitPdfHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ export class SplitPdfHook
splitSize,
)

const oneSecond = 1000;
const oneMinute = 1000 * 60;
const sixtyMinutes = oneMinute * 60;

const headers = prepareRequestHeaders(request);

const requests: Request[] = [];
Expand All @@ -185,11 +189,10 @@ export class SplitPdfHook
file.name,
firstPageNumber
);
const timeoutInMs = 60 * 10 * 1000;
const req = new Request(requestClone, {
headers,
body,
signal: AbortSignal.timeout(timeoutInMs)
signal: AbortSignal.timeout(sixtyMinutes)
});
requests.push(req);
setIndex+=1;
Expand All @@ -203,15 +206,14 @@ export class SplitPdfHook
// These are the retry values from our api spec
// We need to hardcode them here until we're able to reuse the SDK
// from within this hook
const oneSecond = 1000;
const oneMinute = 1000 * 60;

const retryConfig = {
strategy: "backoff",
backoff: {
initialInterval: oneSecond * 3,
maxInterval: oneMinute * 12,
exponent: 1.88,
maxElapsedTime: oneMinute * 30,
maxElapsedTime: sixtyMinutes,
},
} as RetryConfig;

Expand All @@ -223,7 +225,7 @@ export class SplitPdfHook
try {
const response = await retry(
async () => {
return await this.client!.request(req.clone());
return await this.client!.request(req);
},
{ config: retryConfig, statusCodes: retryCodes }
);
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/custom/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export class HTTPClientExtension extends HTTPClient {
}

override async request(request: Request): Promise<Response> {
if (request.url === "https://no-op/") {
const clone = request.clone();
if (clone.url === "https://no-op/") {
return new Response('{}', {
headers: [
["fake-response", "fake-response"]
Expand All @@ -41,6 +42,6 @@ export class HTTPClientExtension extends HTTPClient {
statusText: 'OK_NO_OP'
});
}
return super.request(request);
return super.request(clone);
}
}
Loading