fix(cli/worker): Print error stacks from the origin Worker (#7987)

Fixes #4728
This commit is contained in:
Nayeem Rahman 2020-10-20 05:05:42 +01:00 committed by GitHub
parent 57e95032c8
commit 7aba07cc77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 172 additions and 46 deletions

View file

@ -3,6 +3,7 @@
((window) => {
const core = window.Deno.core;
const { Window } = window.__bootstrap.globalInterfaces;
const { log } = window.__bootstrap.util;
function createWorker(
@ -142,7 +143,14 @@
if (type === "terminalError") {
this.#terminated = true;
if (!this.#handleError(event.error)) {
throw Error(event.error.message);
if (globalThis instanceof Window) {
throw new Error("Unhandled error event reached main worker.");
} else {
core.jsonOpSync(
"op_host_unhandled_error",
{ message: event.error.message },
);
}
}
continue;
}
@ -154,7 +162,14 @@
if (type === "error") {
if (!this.#handleError(event.error)) {
throw Error(event.error.message);
if (globalThis instanceof Window) {
throw new Error("Unhandled error event reached main worker.");
} else {
core.jsonOpSync(
"op_host_unhandled_error",
{ message: event.error.message },
);
}
}
continue;
}