diff options
Diffstat (limited to 'core/runtime.rs')
-rw-r--r-- | core/runtime.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/core/runtime.rs b/core/runtime.rs index 873167388..7f71af09a 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -901,9 +901,13 @@ impl JsRuntime { let mut receiver = self.mod_evaluate_inner(id)?; poll_fn(|cx| { - if let Poll::Ready(result) = receiver.poll_next_unpin(cx) { - debug!("received module evaluate"); - return Poll::Ready(result.unwrap()); + if let Poll::Ready(maybe_result) = receiver.poll_next_unpin(cx) { + debug!("received module evaluate {:#?}", maybe_result); + // If `None` is returned it means that runtime was destroyed before + // evaluation was complete. This can happen in Web Worker when `self.close()` + // is called at top level. + let result = maybe_result.unwrap_or(Ok(())); + return Poll::Ready(result); } let _r = self.poll_event_loop(cx)?; Poll::Pending |