@@ -489,6 +489,8 @@ class Driver {
489489 const benchmarkResultsUI = document . getElementById ( `benchmark-${ benchmark . name } ` ) ;
490490 benchmarkResultsUI . classList . remove ( "benchmark-running" ) ;
491491 benchmarkResultsUI . classList . add ( "benchmark-error" ) ;
492+
493+ this . reportErrorToRunBenchmarkRunner ( ) ;
492494 }
493495
494496 pushError ( name , error ) {
@@ -643,14 +645,23 @@ class Driver {
643645 }
644646
645647 async reportScoreToRunBenchmarkRunner ( )
648+ {
649+ await this . postToRunBenchmarkRunner ( this . resultsJSON ( ) ) ;
650+ }
651+
652+ async reportErrorToRunBenchmarkRunner ( )
653+ {
654+ await this . postToRunBenchmarkRunner ( JSON . stringify ( { errors : this . errors } ) ) ;
655+ }
656+
657+ async postToRunBenchmarkRunner ( content )
646658 {
647659 if ( ! isInBrowser )
648660 return ;
649661
650662 if ( ! JetStreamParams . report )
651663 return ;
652664
653- const content = this . resultsJSON ( ) ;
654665 await fetch ( "/report" , {
655666 method : "POST" ,
656667 headers : {
@@ -829,7 +840,13 @@ class ShellScripts extends Scripts {
829840class BrowserScripts extends Scripts {
830841 constructor ( preloads ) {
831842 super ( preloads ) ;
832- this . add ( "window.onerror = top.currentReject;" ) ;
843+ // Rejected promises that nobody handles never reach window.onerror, ex: a wasm module that doesn't
844+ // compile hangs the run.
845+ this . add ( `(() => {
846+ const reject = top.currentReject;
847+ window.onerror = (message, source, lineno, colno, error) => reject(error ?? message);
848+ window.onunhandledrejection = (event) => reject(event.reason);
849+ })();` ) ;
833850 }
834851
835852 run ( ) {
@@ -1815,9 +1832,7 @@ class AsyncWasmLegacyBenchmark extends Benchmark {
18151832 try {
18161833 andThen();
18171834 } catch(e) {
1818- console.log("error running wasm:", e);
1819- console.log(e.stack);
1820- throw e;
1835+ top.currentReject(e);
18211836 }
18221837 });
18231838 ` ;
@@ -1829,11 +1844,7 @@ class AsyncWasmLegacyBenchmark extends Benchmark {
18291844 preloadCount ++ ;
18301845 str += `JetStream.loadBlob(${ JSON . stringify ( name ) } , "${ resource } ", () => {\n` ;
18311846 }
1832- str += `doRun().catch((e) => {
1833- console.log("error running wasm:", e);
1834- console.log(e.stack)
1835- throw e;
1836- });` ;
1847+ str += `doRun().catch((error) => { top.currentReject(error); });` ;
18371848 for ( let i = 0 ; i < preloadCount ; ++ i ) {
18381849 str += `})` ;
18391850 }
0 commit comments