Skip to content

Commit

Permalink
Add clearTimeout for abort controller fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
synzen committed Jan 28, 2024
1 parent 9a69860 commit f85a695
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export class FeedFetcherService {

const sizeOfTextInMb = Buffer.byteLength(text) / 1024 / 1024;

if (sizeOfTextInMb > 5) {
if (sizeOfTextInMb > 7) {
throw new FeedTooLargeException(`Response body is too large`);
}

Expand Down Expand Up @@ -347,7 +347,7 @@ export class FeedFetcherService {
): Promise<ReturnType<typeof fetch>> {
const controller = new AbortController();

setTimeout(() => {
const timer = setTimeout(() => {
controller.abort();
}, this.feedRequestTimeoutMs);

Expand All @@ -369,6 +369,8 @@ export class FeedFetcherService {

const res = await fetch(url, useOptions);

clearTimeout(timer);

return res;
}

Expand Down

0 comments on commit f85a695

Please sign in to comment.