mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Fix errors when postgres returns undefined and trying to save to redis
This commit is contained in:
parent
6edd71194b
commit
dc5158257e
1 changed files with 2 additions and 1 deletions
|
@ -21,7 +21,8 @@ async function get<T>(fetchFromDB: () => Promise<T>, key: string): Promise<T> {
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue