deno
deno copied to clipboard
Deno panics import node:process from within a vm.Script
Version: Deno 1.40.5
x.ts:
import vm from "node:vm";
const script = new vm.Script("import('node:process')");
script.runInNewContext();
❯ deno run x.ts
============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.
Platform: macos aarch64
Version: 1.40.5
Args: ["deno", "run", "x.ts"]
thread 'main' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.262.0/runtime/jsrealm.rs:206:46:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
This appears to be this file in deno_core: https://github.com/denoland/deno_core/blob/83906063c4c493a40958e4912c424c382c8afedb/core/runtime/jsrealm.rs#L206
It also seems to be present regardless of what you import from inside of the vm.Script, whether it's a node builtin, a local file, or an npm:
prefixed import.
Still segfaults in 1.42.4
# deno run /tmp/foo.js
============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.
Platform: macos aarch64
Version: 1.42.4
Args: ["deno", "run", "/tmp/foo.js"]
thread 'main' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.275.0/runtime/jsrealm.rs:208:46:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The gist of the problem is that node:vm
creates a new V8 context, but it doesn't create related structures that would be set up for every single context - JsRealm
, ModuleMap
and ContextState
. We will need to move some parts of node:vm
module to be integrated directly with deno_core
in order to solve this issue.