Openstatus www.openstatus.dev
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

hotfix when third retry (#111)

authored by

Thibault Le Ouay and committed by
GitHub
6ca9719d df0babea

+18 -6
+18 -6
apps/web/src/app/api/checker/regions/_checker.ts
··· 19 19 const tb = new Tinybird({ token: env.TINY_BIRD_API_KEY }); 20 20 21 21 const monitor = async ( 22 - res: Response, 22 + res: { text: () => Promise<string>; status: number }, 23 23 monitorInfo: z.infer<typeof payloadSchema>, 24 24 region: string, 25 25 latency: number, ··· 77 77 throw new Error("Invalid response body"); 78 78 } 79 79 80 - const startTime = Date.now(); 81 - const res = await fetch(result.data.url, { cache: "no-store" }); 82 - const endTime = Date.now(); 83 - const latency = endTime - startTime; 80 + try { 81 + const startTime = Date.now(); 82 + const res = await fetch(result.data.url, { cache: "no-store" }); 84 83 85 - await monitor(res, result.data, region, latency); 84 + const endTime = Date.now(); 85 + const latency = endTime - startTime; 86 + await monitor(res, result.data, region, latency); 87 + } catch (e) { 88 + // if on the third retry we still get an error, we should report it 89 + if (request.headers.get("Upstash-Retried") === "3") { 90 + await monitor( 91 + { status: 500, text: () => Promise.resolve(`${e}`) }, 92 + result.data, 93 + region, 94 + -1, 95 + ); 96 + } 97 + } 86 98 };