Skip to content

vm.runInContext() breaks delete on v18.2.0 #43129

Closed
@alexlamsl

Description

@alexlamsl

Version

v18.2.0

Platform

Microsoft Windows [Version 10.0.14393]

Subsystem

vm

What steps will reproduce the bug?

$ cat test.js
var a = "direct";
delete a;
console.log(a);

var vm = require('vm');

vm.runInThisContext(`
var b = "this";
delete b;
console.log(b);
`);

vm.runInContext(`
var c = "new";
delete c;
console.log(c);
`, vm.createContext({ console: console }));

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

$ node -v
v4.9.1
v6.17.1
v8.17.0
v10.24.1
v12.22.12
v14.19.1
v16.14.2
v18.0.0

$ cat test.js | node
direct
this
new

What do you see instead?

$ node -v
v18.2.0

$ cat test.js | node
direct
this
undefined

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    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