diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2021-10-01 10:30:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-01 11:30:55 +0200 |
commit | b354eaa2475a16f66e99efc82bebf5bd620406e4 (patch) | |
tree | aa8d15ba548032e44834bb736b1d32882bf60688 /runtime/web_worker.rs | |
parent | c0b6c0eea59f0bea0ab12b2949a7c37c1a774293 (diff) |
fix(runtime/js/workers): throw errors instead of using an op (#12249)
Diffstat (limited to 'runtime/web_worker.rs')
-rw-r--r-- | runtime/web_worker.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs index 98a8ae076..1ca5deb7a 100644 --- a/runtime/web_worker.rs +++ b/runtime/web_worker.rs @@ -525,15 +525,8 @@ impl WebWorker { return Poll::Ready(Ok(())); } - // In case of an error, pass to parent without terminating worker if let Err(e) = r { - print_worker_error(e.to_string(), &self.name); - let handle = self.internal_handle.clone(); - handle - .post_event(WorkerControlEvent::Error(e)) - .expect("Failed to post message to host"); - - return Poll::Pending; + return Poll::Ready(Err(e)); } panic!( @@ -593,6 +586,12 @@ pub fn run_web_worker( return Ok(()); } + let result = if result.is_ok() { + worker.run_event_loop(true).await + } else { + result + }; + if let Err(e) = result { print_worker_error(e.to_string(), &name); internal_handle @@ -603,7 +602,6 @@ pub fn run_web_worker( return Ok(()); } - let result = worker.run_event_loop(true).await; debug!("Worker thread shuts down {}", &name); result }; |