File tree Expand file tree Collapse file tree
packages/core/src/runtime Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,9 +31,15 @@ import { getDebugSurface } from "./globals.js";
3131
3232/** The named error readiness waits fail with once start-up or a timeline post throws; it stays set. */
3333export function recordStartupError ( error : unknown ) : void {
34- const detail = error instanceof Error ? `${ error . name } : ${ error . message } ` : String ( error ) ;
34+ let detail = "unknown error" ;
35+ try {
36+ detail = error instanceof Error ? `${ error . name } : ${ error . message } ` : String ( error ) ;
37+ } catch ( err ) {
38+ swallow ( "runtime.startupError" , err ) ;
39+ }
3540 ( window as Window & { __hfStartupError ?: string } ) . __hfStartupError =
36- `HyperFrames runtime failed: ${ detail } . Fix the composition script or window.__timelines entry that threw.` ;
41+ `HyperFrames runtime failed: ${ detail } . Check the composition's scripts and window.__timelines ` +
42+ `entries; if they look right, report this as a HyperFrames bug.` ;
3743}
3844
3945export function swallow ( label : string , error ?: unknown ) : void {
Original file line number Diff line number Diff line change @@ -42,7 +42,20 @@ describe("runtime start-up failure", () => {
4242
4343 await expect ( evaluateRuntime ( ) ) . rejects . toThrow ( "boom" ) ;
4444 expect ( window . __hfStartupError ) . toContain ( "HyperFrames runtime failed: TypeError: boom" ) ;
45- expect ( window . __hfStartupError ) . toContain ( "Fix the composition script or window.__timelines entry" ) ;
45+ expect ( window . __hfStartupError ) . toContain ( "Check the composition's scripts and window.__timelines" ) ;
46+ } ) ;
47+
48+ it ( "still records the failure when the thrown value cannot be printed" , async ( ) => {
49+ const thrown : unknown = Object . create ( null ) ;
50+ vi . doMock ( "./init" , async ( importOriginal ) => ( {
51+ ...( await importOriginal < typeof import ( "./init" ) > ( ) ) ,
52+ initSandboxRuntimeModular : ( ) => {
53+ throw thrown ;
54+ } ,
55+ } ) ) ;
56+
57+ await expect ( evaluateRuntime ( ) ) . rejects . toBe ( thrown ) ;
58+ expect ( window . __hfStartupError ) . toContain ( "HyperFrames runtime failed: unknown error." ) ;
4659 } ) ;
4760
4861 it ( "is not marked render-ready when posting the timeline throws" , async ( ) => {
You can’t perform that action at this time.
0 commit comments