Skip to content

Commit dc51582

Browse files
committed
Fix errors when postgres returns undefined and trying to save to redis
1 parent 6edd711 commit dc51582

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/utils/queryCacher.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ async function get<T>(fetchFromDB: () => Promise<T>, key: string): Promise<T> {
2121

2222
const data = await fetchFromDB();
2323

24-
redis.setExWithCache(key, config.redis?.expiryTime, JSON.stringify(data)).catch((err) => Logger.error(err));
24+
// Undefined can't be stringified, but null can
25+
redis.setExWithCache(key, config.redis?.expiryTime, JSON.stringify(data ?? null)).catch((err) => Logger.error(err));
2526

2627
return data;
2728
}

0 commit comments

Comments
 (0)