Skip to content

vm.runInContext rewrites thrown error messages #2104

Closed
@domenic

Description

@domenic
"use strict";
const vm = require("vm");

try {
  vm.runInContext("throw new Error('boo');", vm.createContext({}));
} catch (e) {
  console.log(e.message);
}

Should give: boo

Instead gives:

$ iojs test.js
evalmachine.<anonymous>:1
throw new Error('boo');
      ^
boo

Modifying the actual .message property here seems very, very bad.

/cc @indutny since I believe you made changes to the error-message related stuff a while back.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.vmIssues and PRs related to the vm subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions