Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add await into worker.ts #5910

Closed
wants to merge 1 commit into from

Conversation

samuelteixeiras
Copy link

I am running this code on Mac, if I did not add that await in the front of the console.log I have the error:

deno run --allow-read main.ts 
hello world
thread 'deno-worker-0' panicked at 'Failed to post message to host: TrySendError { kind: Disconnected }', cli/ops/worker_host.rs:142:7
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'Worker thread panicked: Any', cli/ops/worker_host.rs:329:11

If that await before the console.log is not be needed this is possible bug.

I am running this code on Mac, if I did not add that 'await' in the front of the console.log I have the error:

deno run --allow-read main.ts 
hello world
thread 'deno-worker-0' panicked at 'Failed to post message to host: TrySendError { kind: Disconnected }', cli/ops/worker_host.rs:142:7
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'Worker thread panicked: Any', cli/ops/worker_host.rs:329:11
@CLAassistant
Copy link

CLAassistant commented May 27, 2020

CLA assistant check
All committers have signed the CLA.

@pgasiorowski
Copy link

Ubuntu 18 also panicks but with slightly different stacktrace pointing at src/libcore/result.rs:1188:5:

$ RUST_BACKTRACE=1 deno run --allow-read main.ts 
hello world
thread 'deno-worker-0' panicked at 'Failed to post message to host: TrySendError { kind: Disconnected }', src/libcore/result.rs:1188:5
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: std::panicking::rust_panic_with_hook
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::result::unwrap_failed
   9: core::result::Result<T,E>::expect
             at /usr/src/rustc-1.41.0/src/libcore/result.rs:983
  10: deno::ops::worker_host::run_worker_thread::{{closure}}
             at cli/ops/worker_host.rs:142
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'main' panicked at 'Worker thread panicked: Any', src/libcore/result.rs:1188:5
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: std::panicking::rust_panic_with_hook
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::result::unwrap_failed
   9: core::result::Result<T,E>::expect
             at /usr/src/rustc-1.41.0/src/libcore/result.rs:983
  10: deno::ops::worker_host::op_host_get_message::{{closure}}
             at cli/ops/worker_host.rs:332
  11: <std::future::GenFuture<T> as core::future::future::Future>::poll
             at /usr/src/rustc-1.41.0/src/libstd/future.rs:43
  12: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /usr/src/rustc-1.41.0/src/libcore/future/future.rs:119
  13: futures_util::future::future::chain::Chain<Fut1,Fut2,Data>::poll
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.4/src/future/future/chain.rs:44
  14: <futures_util::future::future::then::Then<Fut1,Fut2,F> as core::future::future::Future>::poll
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.4/src/future/future/then.rs:44
  15: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /usr/src/rustc-1.41.0/src/libcore/future/future.rs:119
  16: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.4/src/future/future/map.rs:40
  17: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /usr/src/rustc-1.41.0/src/libcore/future/future.rs:119
  18: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.4/src/future/future/map.rs:40
  19: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /usr/src/rustc-1.41.0/src/libcore/future/future.rs:119
  20: <futures_util::stream::futures_unordered::FuturesUnordered<Fut> as futures_core::stream::Stream>::poll_next
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.4/src/stream/futures_unordered/mod.rs:544
  21: <&mut S as futures_core::stream::Stream>::poll_next
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.4/src/stream.rs:102
  22: <futures_util::stream::stream::fuse::Fuse<S> as futures_core::stream::Stream>::poll_next
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.4/src/stream/stream/fuse.rs:85
  23: futures_util::stream::select::poll_inner
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.4/src/stream/select.rs:115
  24: <futures_util::stream::select::Select<St1,St2> as futures_core::stream::Stream>::poll_next
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.4/src/stream/select.rs:100
  25: futures_util::stream::stream::StreamExt::poll_next_unpin
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.4/src/stream/stream/mod.rs:1184
  26: <deno_core::isolate::CoreIsolate as core::future::future::Future>::poll
             at core/isolate.rs:507
  27: <alloc::boxed::Box<F> as core::future::future::Future>::poll
             at /usr/src/rustc-1.41.0/src/liballoc/boxed.rs:1182
  28: futures_util::future::future::FutureExt::poll_unpin
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.4/src/future/future/mod.rs:507
  29: <deno_core::es_isolate::EsIsolate as core::future::future::Future>::poll
             at core/es_isolate.rs:582
  30: <alloc::boxed::Box<F> as core::future::future::Future>::poll
             at /usr/src/rustc-1.41.0/src/liballoc/boxed.rs:1182
  31: futures_util::future::future::FutureExt::poll_unpin
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.4/src/future/future/mod.rs:507
  32: <deno::worker::Worker as core::future::future::Future>::poll
             at cli/worker.rs:220
  33: <&mut F as core::future::future::Future>::poll
             at /usr/src/rustc-1.41.0/src/libcore/future/future.rs:107
  34: std::future::poll_with_tls_context
             at /usr/src/rustc-1.41.0/src/libstd/future.rs:99
  35: deno::run_command::{{closure}}
             at cli/main.rs:518
  36: <std::future::GenFuture<T> as core::future::future::Future>::poll
             at /usr/src/rustc-1.41.0/src/libstd/future.rs:43
  37: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /usr/src/rustc-1.41.0/src/libcore/future/future.rs:119
  38: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on::{{closure}}::{{closure}}
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.20/src/runtime/basic_scheduler.rs:131
  39: tokio::coop::budget::{{closure}}
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.20/src/coop.rs:97
  40: std::thread::local::LocalKey<T>::try_with
             at /usr/src/rustc-1.41.0/src/libstd/thread/local.rs:262
  41: std::thread::local::LocalKey<T>::with
             at /usr/src/rustc-1.41.0/src/libstd/thread/local.rs:239
  42: tokio::coop::budget
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.20/src/coop.rs:79
  43: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on::{{closure}}
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.20/src/runtime/basic_scheduler.rs:131
  44: tokio::runtime::basic_scheduler::enter::{{closure}}
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.20/src/runtime/basic_scheduler.rs:213
  45: tokio::macros::scoped_tls::ScopedKey<T>::set
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.20/src/macros/scoped_tls.rs:64
  46: tokio::runtime::basic_scheduler::enter
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.20/src/runtime/basic_scheduler.rs:213
  47: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.20/src/runtime/basic_scheduler.rs:123
  48: tokio::runtime::Runtime::block_on::{{closure}}
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.20/src/runtime/mod.rs:444
  49: tokio::runtime::context::enter
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.20/src/runtime/context.rs:72
  50: tokio::runtime::handle::Handle::enter
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.20/src/runtime/handle.rs:71
  51: tokio::runtime::Runtime::block_on
             at /home/woodzu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.20/src/runtime/mod.rs:441
  52: deno::tokio_util::run_basic
             at cli/tokio_util.rs:18
  53: deno::main
             at cli/main.rs:669
  54: std::rt::lang_start::{{closure}}
             at /usr/src/rustc-1.41.0/src/libstd/rt.rs:67
  55: std::panicking::try::do_call
  56: __rust_maybe_catch_panic
  57: std::rt::lang_start_internal
  58: std::rt::lang_start
             at /usr/src/rustc-1.41.0/src/libstd/rt.rs:67
  59: main
  60: __libc_start_main
  61: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@pgasiorowski
Copy link

Duplicate of #5334

@bartlomieju
Copy link
Member

@samuelteixeiras thanks for the patch, but it's not really a valid solution. The problem you're seeing is described in #5334 and requires fixing Rust ops. As a temporary workaround you can add short delay before closing the worker. Closing without merge

@samuelteixeiras
Copy link
Author

thank you for the response @bartlomieju and @WooDzu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants