Skip to content

Cannot use new BroadcastChannel(name) #3323

@diego-aquino

Description

@diego-aquino

Description of Bug

Calling new BroadcastChannel(name) inside a Node.js context in StackBlitz is causing the following error:

❯ node
Welcome to Node.js v20.19.0.
Type ".help" for more information.
> new BroadcastChannel('example')
Uncaught TypeError: Cannot read properties of undefined (reading 'on')
    at _0x1c74ce.runInContext (https://vitejsviteviaqn3q5-a0bn.w-credentialless-staticblitz.com/blitz.fb22cd3d.js:31:883177)
    at _0x1c74ce.runInThisContext (node:vm:322:1534)
    at REPLServer.defaultEval (node:repl:303:7356)
    at bound (node:domain:29:4669)
    at REPLServer.runBound (node:domain:29:4696)
    at REPLServer.onLine (node:repl:303:13910)
    at REPLServer.emit (node:events:30:11150)
    at REPLServer.emit (node:domain:29:5199)
    at [_onLine].[as (node:internal/readline/interface:203:5329)
    at [_line].[as (node:internal/readline/interface:203:10230)

Steps to Reproduce

  1. Go to https://stackblitz.com/edit/vitejs-vite-viaqn3q5
  2. Run node in the terminal
  3. Run new BroadcastChannel('example')
  4. See error

Expected Behavior

I expected that a new broadcast channel would be created. The error does not happen locally, even using the same Node.js version as StackBlitz (currently 20.19.0):

> node
Welcome to Node.js v20.19.0.
Type ".help" for more information.
> new BroadcastChannel('example')
BroadcastChannel { name: 'example', active: true }

Screenshots/Screencast

Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions