Skip to content

node:vm does not not implement createContext correctly #31192

@YieldRay

Description

@YieldRay

Version: Deno 2.5.6

This code will fail:

import vm from "node:vm";
const ctx = vm.createContext(vm.constants.DONT_CONTEXTIFY);
error: Uncaught (in promise) TypeError: The "object" argument must be of type object. Received type symbol (Symbol(DONT_CONTEXTIFY)) 
    at __node_internal_ (ext:deno_node/internal/validators.mjs:124:11)
    at isContext (node:vm:193:3)
    at Object.createContext (node:vm:122:7)

According to the Node.js docs, this feature was added in v22.8.0 and v20.18.0.

So, this error may show that Deno does not fully support this Node.js feature yet.

However, this is not mentioned in the Deno documentation (link).


I opened this issue because I found that jsdom cannot run with deno.

import { JSDOM } from "jsdom";
const jsdom = await JSDOM.fromURL("https://example.net/", {
  runScripts: "dangerously", // <-
});

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions