1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-29 16:07:40 +01:00

fix: use AbortSignal.timeout instead of setTimeout

Signed-off-by: Megh Rathod <me@meghrathod.dev>
This commit is contained in:
Megh Rathod 2024-04-12 23:29:42 +05:30
parent 1ec51699d1
commit 76d906c95a
No known key found for this signature in database

View file

@ -156,13 +156,6 @@ const headers = {
async function get<T>(url: string, params?: object): Promise<T> {
if (!apiKey) throw new Error("TMDB API key not set");
const controller = new AbortController();
const { signal } = controller;
const timeoutId =
baseURL === otherUrl
? setTimeout(() => controller.abort(), 15000)
: setTimeout(() => controller.abort(), 3000);
let res: Promise<T>;
try {
@ -172,9 +165,8 @@ async function get<T>(url: string, params?: object): Promise<T> {
params: {
...params,
},
signal,
signal: AbortSignal.timeout(baseURL !== otherUrl ? 5000 : 30000),
});
clearTimeout(timeoutId);
} catch (err) {
if (baseURL !== otherUrl) {
baseURL = otherUrl;