From 23bb3c39d0c0335711a72f588a8ccfdcc7628de2 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Thu, 6 Aug 2026 17:30:26 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(frontend)=20normalize=20thrown=20v?= =?UTF-8?q?alues=20into=20proper=20Error=20instances?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LiveKit can surface raw DOM events (for example WebSocket "error" events, whose only enumerable key is `isTrusted`) instead of Error instances. When such a value ends up being captured, our error reporting logs it as "Event: Event captured as exception with keys: isTrusted", which is unhelpful and hides the real cause. Add a small helper that normalizes any unknown thrown or emitted value into a proper Error, preserving the original payload as context. Fixes 01997b9a-db63-7fc2-8fe4-f21dd7fd608d. --- .../src/features/rooms/components/Conference.tsx | 3 ++- src/frontend/src/features/rooms/utils/error.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/frontend/src/features/rooms/utils/error.ts diff --git a/src/frontend/src/features/rooms/components/Conference.tsx b/src/frontend/src/features/rooms/components/Conference.tsx index 1e6d1f25..18c576d9 100644 --- a/src/frontend/src/features/rooms/components/Conference.tsx +++ b/src/frontend/src/features/rooms/components/Conference.tsx @@ -37,6 +37,7 @@ import { notifyAutoMutedOnJoin } from '@/features/notifications/utils' import { useSnapshot } from 'valtio' import { userPreferencesStore } from '@/stores/userPreferences' import { userStore } from '@/stores/user' +import { asError } from '../utils/error' export const Conference = ({ roomId, @@ -235,7 +236,7 @@ export const Conference = ({ backgroundColor: 'primaryDark.50 !important', })} onError={(e) => { - posthog.captureException(e) + posthog.captureException(asError(e)) }} onConnected={async () => { if (!apiConfig) return diff --git a/src/frontend/src/features/rooms/utils/error.ts b/src/frontend/src/features/rooms/utils/error.ts new file mode 100644 index 00000000..c7556b39 --- /dev/null +++ b/src/frontend/src/features/rooms/utils/error.ts @@ -0,0 +1,9 @@ +export const asError = (value: unknown): Error => { + if (value instanceof Error) return value + if (value instanceof Event) { + return new Error( + `Unhandled event "${value.type}" from ${value.target?.constructor.name ?? 'unknown'}` + ) + } + return new Error(String(value)) +}