From 79a86ee4c28ed82944196a4f635a484ee95c1c29 Mon Sep 17 00:00:00 2001 From: Jeff Emmett <46964190+Jeff-Emmett@users.noreply.github.com> Date: Sun, 8 Dec 2024 19:57:25 -0500 Subject: [PATCH] videochat debug --- src/App.tsx | 11 +++++++++++ src/shapes/VideoChatShapeUtil.tsx | 13 +++++++++++++ worker/worker.ts | 7 ++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index a776046..871dd98 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -50,6 +50,17 @@ export default function InteractiveShapeExample() { //createRoot(document.getElementById("root")!).render() function App() { + if (process.env.NODE_ENV === "production") { + // Disable all console logs in production + console.log = () => {} + console.debug = () => {} + console.info = () => {} + + // Keep error and warn for debugging + // console.error = () => {}; + // console.warn = () => {}; + } + return ( diff --git a/src/shapes/VideoChatShapeUtil.tsx b/src/shapes/VideoChatShapeUtil.tsx index 7666c21..e3cb3c1 100644 --- a/src/shapes/VideoChatShapeUtil.tsx +++ b/src/shapes/VideoChatShapeUtil.tsx @@ -3,6 +3,12 @@ import { useEffect, useState, useRef } from "react" import { WORKER_URL } from "../routes/Board" import DailyIframe from "@daily-co/daily-js" +interface Window { + DailyIframe: { + setLogLevel(level: "error" | "warn" | "info" | "debug"): void + } +} + export type IVideoChatShape = TLBaseShape< "VideoChat", { @@ -160,6 +166,13 @@ export class VideoChatShape extends BaseBoxShapeUtil { .finally(() => setIsLoading(false)) }, []) + // useEffect(() => { + // // Disable Daily.co debug logs + // if (window.DailyIframe) { + // window.DailyIframe.setLogLevel("error") + // } + // }, []) + if (isLoading) { return (
({ return corsify(response) }, ], - catch: (e) => { + catch: (e: Error) => { + // Silently handle WebSocket errors, but log other errors + if (e.message?.includes("WebSocket")) { + console.debug("WebSocket error:", e) + return new Response(null, { status: 400 }) + } console.error(e) return error(e) },