Skip to content

Object.getOwnPropertySymbols not returning all symbols when using vm #47717

@dubzzz

Description

@dubzzz

Version

18.16.0

Platform

Linux codespaces-261118 5.4.0-1105-azure #111~18.04.1-Ubuntu SMP Fri Mar 3 22:47:43 UTC 2023 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Here is a repro:

// Arrange
const assert = require("assert");
const vm = require("vm");
const global = vm.runInContext("this", vm.createContext());
const totoSymbol = Symbol.for("toto");
const titiSymbol = Symbol.for("titi");

// Act
Object.defineProperty(global, totoSymbol, {
  enumerable: true,
  writable: true,
  value: 4,
  configurable: true,
});
global[titiSymbol] = 4;

// Assert
assert(Object.getOwnPropertySymbols(global).includes(totoSymbol)); // fails with: >=18.2.0 <18.16.0, >=19.0.0 <19.7.0
assert(Object.getOwnPropertySymbols(global).includes(titiSymbol)); // fails with: 18.x, 19.x

Related to jestjs/jest#13338

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

Always.

What is the expected behavior? Why is that the expected behavior?

Both asserts should pass. As they used to in v16.

What do you see instead?

One of the assert is still failing with the last releases of node 18 and 19. The other one has been fixed.

Additional information

A PR fixing the issue has already been opened: #47572

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