summaryrefslogtreecommitdiff
path: root/cli/rt/11_workers.js
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2020-10-20 05:05:42 +0100
committerGitHub <noreply@github.com>2020-10-20 15:05:42 +1100
commit7aba07cc7711adfa774afd8e77695f386127c4bc (patch)
tree3325f296ed175cf61b845fa0673e8356f84913b1 /cli/rt/11_workers.js
parent57e95032c898cfdfe795e6924d402fdbe2ae59a8 (diff)
fix(cli/worker): Print error stacks from the origin Worker (#7987)
Fixes #4728
Diffstat (limited to 'cli/rt/11_workers.js')
-rw-r--r--cli/rt/11_workers.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/cli/rt/11_workers.js b/cli/rt/11_workers.js
index 0a726a714..dcf98aee6 100644
--- a/cli/rt/11_workers.js
+++ b/cli/rt/11_workers.js
@@ -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;
}