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

fix(ext/node): basic vm.runInNewContext implementation #21527

Merged
merged 5 commits into from
Dec 11, 2023

Conversation

littledivy
Copy link
Member

@littledivy littledivy commented Dec 10, 2023

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add one or two test cases. Try to evaluate any code and then try to evaluate a code that tries to access something from the global context (and throws).

ext/node/polyfills/vm.ts Outdated Show resolved Hide resolved
ext/node/polyfills/vm.ts Outdated Show resolved Hide resolved
@kt3k
Copy link
Member

kt3k commented Dec 11, 2023

When the given script throws, then it seems panicking. Can this be avoided somehow?

$ cat a.mjs 
import { runInNewContext } from "node:vm";
runInNewContext("throw new Error('abc')");
$ ./target/debug/deno run a.mjs

============================================================
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.38.5
Args: ["./target/debug/deno", "run", "a.mjs"]

thread 'main' panicked at ext/node/ops/v8.rs:53:34:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@littledivy
Copy link
Member Author

Just fixed that @kt3k :)

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@littledivy littledivy enabled auto-merge (squash) December 11, 2023 06:15
@littledivy littledivy merged commit 02e138d into denoland:main Dec 11, 2023
14 checks passed
@littledivy littledivy deleted the vm_run_in_new_context branch December 11, 2023 07:20
kt3k added a commit that referenced this pull request Dec 11, 2023
This change uncomments Node.js compat test cases which was enabled by the
addition of `vm.runInNewContext`
#21527
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.

3 participants