Merged in fix/limit-time-to-response-for-cache-calls (pull request #1990)

fix: add timeout for redis-api calls SW-2635

Approved-by: Michael Zetterberg
This commit is contained in:
Joakim Jäderberg
2025-05-07 09:15:58 +00:00
parent 49fb2c44de
commit b977877e93
3 changed files with 21 additions and 19 deletions

View File

@@ -16,15 +16,14 @@ export async function set<T>(key: string, value: T, ttl: CacheTime) {
},
body: JSON.stringify({ data: value, ttl: getCacheTimeInSeconds(ttl) }),
cache: "no-cache",
signal: AbortSignal.timeout(3_000),
})
)
if (!response || error || !response.ok) {
Sentry.captureMessage("Unable to SET cachekey", {
level: "error",
if (!response || !response.ok || error) {
Sentry.captureException(error ?? new Error("Unable to SET cachekey"), {
extra: {
cacheKey: key,
errorMessage: error instanceof Error ? error.message : undefined,
statusCode: response?.status,
statusText: response?.statusText,
},