Skip to content

Bun allows Object.freeze(globalThis) running runInContext from node:vm #33075

Description

@davidebombelli

What version of Bun is running?

1.3.14+0d9b296af

What platform is your computer?

Linux 6.8.0-124-generic x86_64 x86_64

What steps can reproduce the bug?

import vm from 'node:vm';

const context = vm.createContext();
vm.runInContext('Object.freeze(globalThis);', context);

What is the expected behavior?

in Node.js, the following error is thrown:

evalmachine.<anonymous>:1
Object.freeze(globalThis);
       ^

TypeError: Cannot freeze
    at Object.freeze (<anonymous>)
    at evalmachine.<anonymous>:1:8
    at Script.runInContext (node:vm:149:12)
    at Object.runInContext (node:vm:301:6)
    at file:///home/username/test.js:4:4
    at ModuleJob.run (node:internal/modules/esm/module_job:377:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:671:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)

What do you see instead?

Bun does not throw any error.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions