mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-20 06:52:04 +00:00
fix: improve AL error handling
This commit is contained in:
parent
8ff16ace6d
commit
42977a921b
4 changed files with 10 additions and 12 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ui",
|
||||
"version": "6.3.7",
|
||||
"version": "6.3.8",
|
||||
"license": "BUSL-1.1",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@9.14.4",
|
||||
|
|
|
|||
|
|
@ -27,15 +27,17 @@
|
|||
|
||||
$: episodeCount = Math.max(_episodes(media) ?? 0, eps?.episodeCount ?? 0)
|
||||
|
||||
const { episodes, specialCount } = eps ?? {}
|
||||
$: ({ episodes, specialCount } = eps ?? {})
|
||||
|
||||
const alSchedule: Record<number, Date | undefined> = {}
|
||||
|
||||
for (const { a: airingAt, e: episode } of dedupeAiring(media)) {
|
||||
alSchedule[episode] = new Date(airingAt * 1000)
|
||||
$: {
|
||||
for (const { a: airingAt, e: episode } of dedupeAiring(media)) {
|
||||
alSchedule[episode] = new Date(airingAt * 1000)
|
||||
}
|
||||
}
|
||||
|
||||
$: episodeList = Array.from({ length: episodeCount }, (_, i) => {
|
||||
$: episodeList = media && Array.from({ length: episodeCount }, (_, i) => {
|
||||
const episode = i + 1
|
||||
|
||||
const airingAt = alSchedule[episode]
|
||||
|
|
|
|||
|
|
@ -265,7 +265,6 @@ class AnilistClient {
|
|||
await this.rateLimitPromise
|
||||
// await sleep(1000)
|
||||
const res = await fetch(req, opts)
|
||||
|
||||
if (!res.ok && (res.status === 429 || res.status === 500)) {
|
||||
throw new FetchError(res)
|
||||
}
|
||||
|
|
@ -307,12 +306,11 @@ class AnilistClient {
|
|||
if (error.name === 'AbortError') return undefined
|
||||
if (jobInfo.retryCount > 8) return undefined
|
||||
|
||||
if (error.message === 'Failed to fetch') return this.setRateLimit(60000)
|
||||
if (!(error instanceof FetchError)) return 0
|
||||
if (error.message === 'Failed to fetch' && !error.res.headers.get('retry-after')) return this.setRateLimit(60000)
|
||||
if (error.res.status === 500) return 1000
|
||||
|
||||
const time = (parseInt(error.res.headers.get('retry-after') ?? '60') + 1) * 1000
|
||||
return this.setRateLimit(time)
|
||||
return this.setRateLimit((parseInt(error.res.headers.get('retry-after') ?? '60') + 1) * 1000)
|
||||
})
|
||||
// hacky but prevents query from re-running
|
||||
this.userlists.subscribe(() => undefined)
|
||||
|
|
|
|||
|
|
@ -68,9 +68,7 @@
|
|||
</Tabs.List>
|
||||
</div>
|
||||
<Tabs.Content value='episodes' tabindex={-1}>
|
||||
{#key mediaID}
|
||||
<EpisodesList {media} {eps} {following} />
|
||||
{/key}
|
||||
<EpisodesList {media} {eps} {following} />
|
||||
</Tabs.Content>
|
||||
<Tabs.Content value='threads' tabindex={-1}>
|
||||
{#key mediaID}
|
||||
|
|
|
|||
Loading…
Reference in a new issue