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

Worker.prototype.terminate panicked #4342

Closed
Fenzland opened this issue Mar 13, 2020 · 0 comments · Fixed by #4684
Closed

Worker.prototype.terminate panicked #4342

Fenzland opened this issue Mar 13, 2020 · 0 comments · Fixed by #4684
Assignees

Comments

@Fenzland
Copy link
Contributor

I'm trying to write a worker runner that run both in browser and deno. I terminate the worker with:

if( worker.terminate && typeof worker.terminate === 'function' )
	worker.terminate();

That's run well on deno 0.30 and before. But since 0.32, there is a counterfeit method here, worker.terminate && typeof worker.terminate === 'function' returns true now, but if you really to run it, it'll crash.
On 0.32, a Error with 'Not yet implemented' thrown, we still can use try catch in program. But since 0.33, that change to a panic:

thread 'deno-worker-foo' panicked at 'not yet implemented', cli/worker.rs:50:5
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:84
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1025
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:193
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:210
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:471
  11: std::panicking::begin_panic
  12: deno::ops::worker_host::op_host_terminate_worker
  13: deno::state::State::core_op::{{closure}}
  14: deno_core::ops::OpRegistry::call
  15: deno_core::isolate::Isolate::dispatch_op
  16: deno_core::bindings::send
  17: <extern "C" fn(A0) .> R as rusty_v8::support::CFnFrom<F>>::mapping::c_fn
  18: _ZN2v88internal25FunctionCallbackArguments4CallENS0_15CallHandlerInfoE
  19: _ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEESA_NS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EENS0_16BuiltinArgumentsE
  20: _ZN2v88internalL26Builtin_Impl_HandleApiCallENS0_16BuiltinArgumentsEPNS0_7IsolateE
  21: Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fatal runtime error: failed to initiate panic, error 5

Now we cannot check whether we can this method trustworthy.

  • is there a function here? yep!
  • can we run it? nope!
  • can we run it in try{} and catch something? nope!
  • can we check the deno version via globalThis.Deno and not run before it implemented? no way! it's removed.

so we have to write code only for several version of deno.

feasible solutions

  • remove this method until it's implemented.
  • throw Error like 0.32 instead of panic, so we can catch it.
  • let globalThis.Deno back so we can check the version of deno.
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 a pull request may close this issue.

2 participants