cheogram-www

created pr with cheogram-www/react-compiler-fixes.1 on 2026-11-10T18:57:22Z · by 3c31bc8c
commented on 2026-11-10T18:57:22Z · by 3c31bc8c
Changes are available at https://tangled.org/mrry.band/cheogram-www on branch react-compiler-fixes.
cmds
checkout latest patchset:
ssh pr.pico.sh pull cheogram-www:react-compiler-fixes | git am -3
checkout specific patchset revision:
ssh pr.pico.sh pull cheogram-www:react-compiler-fixes [rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh cheogram-www:react-compiler-fixes
add comment to patch request:
ssh pr.pico.sh comment cheogram-www:react-compiler-fixes "lgtm!"

Patchset cheogram-www/react-compiler-fixes.1 on 2026-11-10T18:57:22Z · commit 316b569

Fix MessageDebugger.tsx for react-compiler
Eric Roberts 2026-11-10T17:33:57Z
The compiler can't handle throwing inside try/catch:

    (BuildHIR::lowerStatement) Support ThrowStatement inside of try/catch

They don't support this because they think you shouldn't do it:

> /*
> * NOTE: we could support this, but a `throw` inside try/catch is using exceptions
> * for control-flow and is generally considered an anti-pattern. we can likely
> * just not support this pattern, unless it really becomes necessary for some reason.
> */

https://github.com/react/react/blob/main/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts#L281-L285

Weird choice IMO but whatever.

Moved to a function outside the component.
Semantic diff summary
1 added, 2 modified, 0 signature changed, 0 removed across 2 analyzed files
+0 -1 scripts/compiler.test.mjs #
......@@ -4,7 +4,6 @@ import { test } from "node:test";
44 import { createServer } from "vite";
55
66 const compilerSkips = new Set([
7- "components/MessageDebugger.tsx",
87 "components/MessageMenuInChat.tsx",
98 "components/Quill.tsx",
109 "components/Register.tsx",
+21 -13 src/components/MessageDebugger.tsx #
......@@ -25,6 +25,26 @@ function exposeMessage(message: ChatMessage) {
2525 console.log(`${name} (window.${name})`, message);
2626 }
2727
28+async function lookupAndExposeMessage(
29+ persistence: Persistence,
30+ m: ChatMessage,
31+ serverId: string,
32+) {
33+ try {
34+ const message = await persistence.getMessage(
35+ m.account(),
36+ m.chatId(),
37+ serverId,
38+ null,
39+ );
40+ if (!message)
41+ throw new Error(`No stored message for server ID ${serverId}`);
42+ exposeMessage(message);
43+ } catch (error) {
44+ console.error("Message debugger lookup failed", serverId, error);
45+ }
46+}
47+
2848 export const MessageDebugger = ({ m }: { m: ChatMessage }) =>
2949 debugEnabled ? <MessageDebuggerButton m={m} /> : null;
3050
......@@ -52,19 +72,7 @@ const MessageDebuggerButton = ({ m }: { m: ChatMessage }) => {
5272 }
5373 clearTimeout(feedbackTimer.current);
5474 feedbackTimer.current = setTimeout(() => setFeedback(""), 1000);
55- try {
56- const message = await persistence.getMessage(
57- m.account(),
58- m.chatId(),
59- serverId,
60- null,
61- );
62- if (!message)
63- throw new Error(`No stored message for server ID ${serverId}`);
64- exposeMessage(message);
65- } catch (error) {
66- console.error("Message debugger lookup failed", serverId, error);
67- }
75+ await lookupAndExposeMessage(persistence, m, serverId);
6876 }}
6977 >
7078 {serverId}
Back to top