Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions JetStreamDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@ class Driver {
const benchmarkResultsUI = document.getElementById(`benchmark-${benchmark.name}`);
benchmarkResultsUI.classList.remove("benchmark-running");
benchmarkResultsUI.classList.add("benchmark-error");

this.reportErrorToRunBenchmarkRunner();
}

pushError(name, error) {
Expand Down Expand Up @@ -643,14 +645,23 @@ class Driver {
}

async reportScoreToRunBenchmarkRunner()
{
await this.postToRunBenchmarkRunner(this.resultsJSON());
}

async reportErrorToRunBenchmarkRunner()
{
await this.postToRunBenchmarkRunner(JSON.stringify({ errors: this.errors }));
}

async postToRunBenchmarkRunner(content)
{
if (!isInBrowser)
return;

if (!JetStreamParams.report)
return;

const content = this.resultsJSON();
await fetch("/report", {
method: "POST",
headers: {
Expand Down Expand Up @@ -829,7 +840,13 @@ class ShellScripts extends Scripts {
class BrowserScripts extends Scripts {
constructor(preloads) {
super(preloads);
this.add("window.onerror = top.currentReject;");
// Rejected promises that nobody handles never reach window.onerror, ex: a wasm module that doesn't
// compile hangs the run.
this.add(`(() => {
const reject = top.currentReject;
window.onerror = (message, source, lineno, colno, error) => reject(error ?? message);
window.onunhandledrejection = (event) => reject(event.reason);
})();`);
}

run() {
Expand Down Expand Up @@ -1815,9 +1832,7 @@ class AsyncWasmLegacyBenchmark extends Benchmark {
try {
andThen();
} catch(e) {
console.log("error running wasm:", e);
console.log(e.stack);
throw e;
top.currentReject(e);
}
});
`;
Expand All @@ -1829,11 +1844,7 @@ class AsyncWasmLegacyBenchmark extends Benchmark {
preloadCount++;
str += `JetStream.loadBlob(${JSON.stringify(name)}, "${resource}", () => {\n`;
}
str += `doRun().catch((e) => {
console.log("error running wasm:", e);
console.log(e.stack)
throw e;
});`;
str += `doRun().catch((error) => { top.currentReject(error); });`;
for (let i = 0; i < preloadCount; ++i) {
str += `})`;
}
Expand Down
2 changes: 1 addition & 1 deletion wasm/tfjs-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -23220,7 +23220,7 @@
console.warn("Fatal error: no binary file found for ./wasm/tfjs-backend-wasm-simd.wasm and ./wasm/tfjs-backend-wasm.wasm");
WebAssembly.instantiate(blob, info).then(function (output) {
receiveInstance(output.instance, output.module);
});
}, readyPromiseReject);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed won't this get picked up by the unhandled promise rejection event?

return {};
// ************************ CHANGE END ************************

Expand Down
Loading