Skip to content

Freezing EventTarget.prototype breaks MessageChannel #49259

@corrideat

Description

@corrideat

Version

v19.9.0

Platform

Linux WORKSTATION 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

node:internal/worker/io:305:30

What steps will reproduce the bug?

Run the following snippet:

Object.freeze(EventTarget.prototype);
new MessageChannel();

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

It always reproduces

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

Freezing prototypes should not affect the behaviour of native methods. In particular, user code should not interfere with internals.

What do you see instead?

node:internal/worker/io:305
  eventEmitter[kNewListener] = function(size, type, ...args) {
                             ^

TypeError: Cannot assign to read only property 'Symbol(kNewListener)' of object '#<MessagePort>'
    at setupPortReferencing (node:internal/worker/io:305:30)
    at MessagePort.oninit (node:internal/worker/io:232:3)
    at Object.<anonymous> (/tmp/tmp.ddwmESs9uN.js:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1275:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at Module.load (node:internal/modules/cjs/loader:1133:32)
    at Module._load (node:internal/modules/cjs/loader:972:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions