From 94b11e929ac48e5677e016064a4d21535d91c53e Mon Sep 17 00:00:00 2001 From: Cora Grant Date: Tue, 27 Aug 2024 11:16:22 -0400 Subject: [PATCH] fix: guard against inspector code crashing screens On real Bus E-ink hardware we saw a mysterious "DOM exception 12" crash that seemed to be caused by the inspector changes. Though the message sending and listening should have already been a no-op when the screen is not "framed", this adds a check for whether the screen is "framed" by the inspector specifically, and otherwise doesn't even attempt to send/listen. This should sidestep any issues with e.g. a screen vendor rendering our pages inside a frame. --- assets/src/components/admin/inspector.tsx | 8 ++++- assets/src/hooks/v2/use_api_response.tsx | 9 ++---- assets/src/util/inspector.ts | 39 ++++++++++++++++++----- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/assets/src/components/admin/inspector.tsx b/assets/src/components/admin/inspector.tsx index ad52782cc..80f23d9f1 100644 --- a/assets/src/components/admin/inspector.tsx +++ b/assets/src/components/admin/inspector.tsx @@ -11,7 +11,12 @@ import { useHistory, useLocation } from "react-router-dom"; import AdminForm from "./admin_form"; import { doSubmit, type Config, type Screen } from "Util/admin"; -import { type Message, sendMessage, useReceiveMessage } from "Util/inspector"; +import { + type Message, + INSPECTOR_FRAME_NAME, + sendMessage, + useReceiveMessage, +} from "Util/inspector"; type ScreenWithId = { id: string; config: Screen }; @@ -90,6 +95,7 @@ const Inspector: ComponentType = () => {