Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(toolbar): swallow fetch errors in web vitals loader (#59975)

posthog[bot]c3298b0c3a2c
diff --git a/frontend/src/toolbar/web-vitals/webVitalsToolbarLogic.ts b/frontend/src/toolbar/web-vitals/webVitalsToolbarLogic.ts
index ee2fec0b3a5e..e2d63bca8341 100644
--- a/frontend/src/toolbar/web-vitals/webVitalsToolbarLogic.ts
+++ b/frontend/src/toolbar/web-vitals/webVitalsToolbarLogic.ts
@@ -71,9 +71,16 @@ export const webVitalsToolbarLogic = kea<webVitalsToolbarLogicType>([
const params = { pathname: window.location.pathname }
- const response = await toolbarFetch(
- `/api/environments/@current/web_vitals${encodeParams(params, '?')}`
- )
+ let response: Response
+ try {
+ response = await toolbarFetch(
+ `/api/environments/@current/web_vitals${encodeParams(params, '?')}`
+ )
+ } catch {
+ // Network-level failures (origin unreachable, CORS, aborted) throw a TypeError.
+ // Degrade the same way we do for a non-OK response — the UI already handles null metrics.
+ return { LCP: null, FCP: null, CLS: null, INP: null } as WebVitalsMetrics
+ }
breakpoint()
if (!response.ok) {