From bd0ed7ce7952182321a18014d794d18498a2b299 Mon Sep 17 00:00:00 2001 From: Miguel Angel Simon Sierra Date: Wed, 18 Nov 2026 14:04:57 -0500 Subject: [PATCH 1/3] test(studio): a sealed preview whose film boots after 8 s comes ready without an error --- .../nle/NLEPreview.slowBoot.test.ts | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/packages/studio/src/components/nle/NLEPreview.slowBoot.test.ts b/packages/studio/src/components/nle/NLEPreview.slowBoot.test.ts index dd2fe322629..466973c50bd 100644 --- a/packages/studio/src/components/nle/NLEPreview.slowBoot.test.ts +++ b/packages/studio/src/components/nle/NLEPreview.slowBoot.test.ts @@ -60,3 +60,51 @@ it("keeps a shadow reload whose runtime boots after 8 s, and its player comes re expect(host.querySelector("hyperframes-player")?.hasAttribute("no-load-timeout")).toBe(false); act(() => root.unmount()); }); + +// fails without the fix: the live player kept its own 8 s deadline and a sealed film that came up later had errored. +it("hands the live preview's load deadline to a host that owns it, so a sealed film booting after 8 s comes ready", async () => { + await import("@hyperframes/player"); + vi.useFakeTimers(); + const host = document.createElement("div"); + document.body.append(host); + const root = createRoot(host); + await act(async () => { + root.render( + React.createElement(NLEPreview, { + projectId: "p", + iframeRef: createRef(), + onIframeLoad: () => {}, + previewSlots: [{ gen: 0, role: "live" }], + onShadowIframeLoad: () => {}, + onShadowReadyChange: () => {}, + onShadowError: () => {}, + setShadowIframeNode: () => {}, + resetPreviewSlots: () => {}, + sandboxOrigin: "opaque", + noLoadTimeout: true, + }), + ); + }); + + const live = host.querySelector< + HTMLElement & { iframeElement: HTMLIFrameElement; ready: boolean } + >("hyperframes-player")!; + const errors: unknown[] = []; + live.addEventListener("error", (event) => errors.push((event as CustomEvent).detail)); + const iframe = live.iframeElement; + act(() => { + iframe.dispatchEvent(new Event("load")); + }); + act(() => { + vi.advanceTimersByTime(10_000); + }); + expect(errors).toEqual([]); + + Object.assign(iframe.contentWindow!, { __player: { getDuration: () => 9 } }); + act(() => { + vi.advanceTimersByTime(1_000); + }); + expect(errors).toEqual([]); + expect(live.ready).toBe(true); + act(() => root.unmount()); +}); From 0faefdee55b91b56a74a62ebf5089d5b013d8bb3 Mon Sep 17 00:00:00 2001 From: Miguel Angel Simon Sierra Date: Wed, 18 Nov 2026 14:18:42 -0500 Subject: [PATCH 2/3] test(studio): wait for the sealed player to mount before reading it --- .../studio/src/components/nle/NLEPreview.slowBoot.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/studio/src/components/nle/NLEPreview.slowBoot.test.ts b/packages/studio/src/components/nle/NLEPreview.slowBoot.test.ts index 466973c50bd..c5b0d3c48ee 100644 --- a/packages/studio/src/components/nle/NLEPreview.slowBoot.test.ts +++ b/packages/studio/src/components/nle/NLEPreview.slowBoot.test.ts @@ -64,6 +64,9 @@ it("keeps a shadow reload whose runtime boots after 8 s, and its player comes re // fails without the fix: the live player kept its own 8 s deadline and a sealed film that came up later had errored. it("hands the live preview's load deadline to a host that owns it, so a sealed film booting after 8 s comes ready", async () => { await import("@hyperframes/player"); + const frameToken = vi + .spyOn(globalThis, "fetch") + .mockResolvedValue({ ok: true, json: async () => ({ token: "T".repeat(43) }) } as Response); vi.useFakeTimers(); const host = document.createElement("div"); document.body.append(host); @@ -84,6 +87,7 @@ it("hands the live preview's load deadline to a host that owns it, so a sealed f noLoadTimeout: true, }), ); + for (let i = 0; i < 10; i += 1) await Promise.resolve(); }); const live = host.querySelector< @@ -106,5 +110,7 @@ it("hands the live preview's load deadline to a host that owns it, so a sealed f }); expect(errors).toEqual([]); expect(live.ready).toBe(true); + expect(live.hasAttribute("sandbox-origin")).toBe(true); act(() => root.unmount()); + frameToken.mockRestore(); }); From f5e9c0500ff6f5082516db0e617e064005a9d1f6 Mon Sep 17 00:00:00 2001 From: Miguel Angel Simon Sierra Date: Wed, 18 Nov 2026 14:32:06 -0500 Subject: [PATCH 3/3] fix(studio): a host can own the live preview's load deadline, so a slow sealed film isn't an error --- packages/studio/src/components/nle/NLEPreview.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/studio/src/components/nle/NLEPreview.tsx b/packages/studio/src/components/nle/NLEPreview.tsx index 6a33f90b707..7d5a210bf17 100644 --- a/packages/studio/src/components/nle/NLEPreview.tsx +++ b/packages/studio/src/components/nle/NLEPreview.tsx @@ -56,6 +56,7 @@ interface NLEPreviewProps extends Pick< fillBox?: boolean; compositionSizeHint?: PreviewCompositionSize; sandboxOrigin?: "opaque"; + noLoadTimeout?: boolean; } export function getPreviewPlayerKey({ @@ -91,6 +92,7 @@ export const NLEPreview = memo(function NLEPreview({ fillBox, compositionSizeHint, sandboxOrigin, + noLoadTimeout, }: NLEPreviewProps) { const activeKey = getPreviewPlayerKey({ projectId, directUrl }); const viewportRef = useRef(null); @@ -518,6 +520,7 @@ export const NLEPreview = memo(function NLEPreview({ portrait={portrait} suppressLoadingOverlay={suppressLoadingOverlay} loadingUi={loadingUi} + noLoadTimeout={noLoadTimeout} sandboxOrigin={sandboxOrigin} style={ directUrl?.includes("/components/")