Skip to content

MessagePort can send messages after closed #42296

Closed
@jrvidal

Description

@jrvidal

Version

v17.7.1

Platform

Linux 5.13.0-30-generic #33~20.04.1-Ubuntu SMP Mon Feb 7 14:25:10 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

worker_threads

What steps will reproduce the bug?

const { MessageChannel } = require('worker_threads');

const ch = new MessageChannel()

ch.port1.onmessage = () => console.log('hey');

ch.port2.close();

ch.port2.postMessage('asdf');

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

Consistently in v17.7.1, v16.14.0 and v14.19.0.

What is the expected behavior?

The program should not log anything, since port2 is closed right before the call to postMessage.

What do you see instead?

The program does log hey.

Additional information

For whatever is worth, both in Chrome (Chromium 98.0.4758.102, V8 9.8.177.11) and Firefox (97.0.2), the message never arrives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    workerIssues and PRs related to Worker support.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions