mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-09 04:57:04 +03:00
Fix errors when postgres returns undefined and trying to save to redis
This commit is contained in:
@@ -21,7 +21,8 @@ async function get<T>(fetchFromDB: () => Promise<T>, key: string): Promise<T> {
|
|||||||
|
|
||||||
const data = await fetchFromDB();
|
const data = await fetchFromDB();
|
||||||
|
|
||||||
redis.setExWithCache(key, config.redis?.expiryTime, JSON.stringify(data)).catch((err) => Logger.error(err));
|
// Undefined can't be stringified, but null can
|
||||||
|
redis.setExWithCache(key, config.redis?.expiryTime, JSON.stringify(data ?? null)).catch((err) => Logger.error(err));
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user