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:
@@ -1,5 +1,7 @@
|
||||
import * as Sentry from "@sentry/nextjs"
|
||||
|
||||
import { safeTry } from "@/utils/safeTry"
|
||||
|
||||
import { cacheLogger } from "../logger"
|
||||
import { API_KEY } from "./client"
|
||||
import { getCacheEndpoint } from "./endpoints"
|
||||
@@ -12,18 +14,20 @@ export async function deleteKey(key: string, opts?: { fuzzy?: boolean }) {
|
||||
endpoint.searchParams.set("fuzzy", "true")
|
||||
}
|
||||
|
||||
const response = await fetch(endpoint, {
|
||||
method: "DELETE",
|
||||
cache: "no-cache",
|
||||
headers: {
|
||||
"x-api-key": API_KEY,
|
||||
},
|
||||
})
|
||||
const [response, error] = await safeTry(
|
||||
fetch(endpoint, {
|
||||
method: "DELETE",
|
||||
cache: "no-cache",
|
||||
headers: {
|
||||
"x-api-key": API_KEY,
|
||||
},
|
||||
signal: AbortSignal.timeout(10_000),
|
||||
})
|
||||
)
|
||||
|
||||
if (!response.ok) {
|
||||
if (response.status !== 404) {
|
||||
Sentry.captureMessage("Unable to DELETE cachekey", {
|
||||
level: "error",
|
||||
if (!response || !response.ok || error) {
|
||||
if (response?.status !== 404) {
|
||||
Sentry.captureException(error ?? new Error("Unable to DELETE cachekey"), {
|
||||
extra: {
|
||||
cacheKey: key,
|
||||
statusCode: response?.status,
|
||||
|
||||
Reference in New Issue
Block a user