Skip to content

Commit

Permalink
Add a 10 second timeout to Jikan calls
Browse files Browse the repository at this point in the history
Due to jikan-me/jikan-rest#269, sometimes Jikan takes a long time to report failures. To save on costs, we should timeout the request quickly and then just retry.
  • Loading branch information
YoshiWalsh committed Nov 3, 2022
1 parent efbb59e commit 4f92005
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@types/chunk": "^0.0.0",
"aws-lambda": "^1.0.7",
"aws-sdk": "^2.1187.0",
"axios": "^0.27.2",
"body-parser": "^1.19.0",
"chunk": "^0.0.3",
"cors": "^2.8.5",
Expand Down
3 changes: 3 additions & 0 deletions server/src/fetching/anime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import { LocalDate, ZonedDateTime, ZoneOffset } from '@js-joda/core';
import { Anime as MarikaAnime, IAnimeFull, IAnimeStats } from '@shineiichijo/marika';
import { ratelimit, retry } from '../utils';
import { Contracts } from "wrongopinions-common";
import { default as axios } from 'axios';

const marika = {
anime: new MarikaAnime(),
}

axios.defaults.timeout = 10 * 1000; // Avoid pointless waiting when https://github.com/jikan-me/jikan-rest/issues/269 occurs

export async function loadAnime(db: DB, queue: QueueDispatcher, id: number): Promise<void> {
console.log("Loading anime", id);
let details: IAnimeFull;
Expand Down

0 comments on commit 4f92005

Please sign in to comment.