fix: 🐛 patron timeout

This commit is contained in:
ThatOneCalculator 2023-07-02 00:16:01 -07:00
parent b5907fb86d
commit 17009455da
No known key found for this signature in database
GPG Key ID: 8703CACD01000000

View File

@ -23,8 +23,15 @@ export default define(meta, paramDef, async (ps) => {
if (!ps.forceUpdate && cachedPatrons) { if (!ps.forceUpdate && cachedPatrons) {
patrons = JSON.parse(cachedPatrons); patrons = JSON.parse(cachedPatrons);
} else { } else {
AbortSignal.timeout ??= function timeout(ms) {
const ctrl = new AbortController()
setTimeout(() => ctrl.abort(), ms)
return ctrl.signal
}
patrons = await fetch( patrons = await fetch(
"https://codeberg.org/calckey/calckey/raw/branch/develop/patrons.json", "https://codeberg.org/calckey/calckey/raw/branch/develop/patrons.json",
{ signal: AbortSignal.timeout(2000) }
) )
.then((response) => response.json()) .then((response) => response.json())
.catch(() => { .catch(() => {