summaryrefslogtreecommitdiff
path: root/cli/worker.rs
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/worker.rs
parent57e95032c898cfdfe795e6924d402fdbe2ae59a8 (diff)
fix(cli/worker): Print error stacks from the origin Worker (#7987)
Fixes #4728
Diffstat (limited to 'cli/worker.rs')
-rw-r--r--cli/worker.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/cli/worker.rs b/cli/worker.rs
index d9d9f61c1..877af3208 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -1,5 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+use crate::colors;
use crate::fmt_errors::JsError;
use crate::inspector::DenoInspector;
use crate::inspector::InspectorSession;
@@ -275,7 +276,7 @@ impl MainWorker {
ops::runtime::init(js_runtime, main_module);
ops::fetch::init(js_runtime, program_state.flags.ca_file.as_deref());
ops::timers::init(js_runtime);
- ops::worker_host::init(js_runtime);
+ ops::worker_host::init(js_runtime, None);
ops::random::init(js_runtime, program_state.flags.seed);
ops::reg_json_sync(js_runtime, "op_close", deno_core::op_close);
ops::reg_json_sync(js_runtime, "op_resources", deno_core::op_resources);
@@ -443,11 +444,11 @@ impl WebWorker {
op_state.put::<Permissions>(permissions);
}
- ops::web_worker::init(js_runtime, sender, handle);
+ ops::web_worker::init(js_runtime, sender.clone(), handle);
ops::runtime::init(js_runtime, main_module);
ops::fetch::init(js_runtime, program_state.flags.ca_file.as_deref());
ops::timers::init(js_runtime);
- ops::worker_host::init(js_runtime);
+ ops::worker_host::init(js_runtime, Some(sender));
ops::reg_json_sync(js_runtime, "op_close", deno_core::op_close);
ops::reg_json_sync(js_runtime, "op_resources", deno_core::op_resources);
ops::reg_json_sync(
@@ -510,6 +511,12 @@ impl WebWorker {
}
if let Err(e) = r {
+ eprintln!(
+ "{}: Uncaught (in worker \"{}\") {}",
+ colors::red_bold("error"),
+ worker.name.to_string(),
+ e.to_string().trim_start_matches("Uncaught "),
+ );
let mut sender = worker.internal_channels.sender.clone();
sender
.try_send(WorkerEvent::Error(e))