Skip to content

BroadcastChannel doesn't fill in useful MessageEvent fields like source, or ports #59053

Description

@jdmarshall

Version

No response

Platform

This makes it difficult to use BroadcastChannel to set up coordinations between worker threads unless they share the same supervisor. 

Which is problematic for things like caching or telemetry.


MessageEvent {
  type: 'message',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 444.018666
}

ports, source are empty strings.

Subsystem

node:worker_threads

What steps will reproduce the bug?

        const util = require('util');
	const channel = new BroadcastChannel('example');

	if (isMainThread) {
		channel.addEventListener('message', evt => {
			console.log(util.inspect(evt)); // breakpoint here
		});
	} else {
		channel.postMessage('hello');
        }

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

Always. Seems to be by design, and the design may have drifted from the current web standards over time.

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

That I get some metadata

What do you see instead?

empty string, empty array.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    workerIssues and PRs related to Worker support.

    Type

    No type

    Fields

    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