Skip to content

node:test hangs when BroadcastChannel is left open #52073

@JakobJingleheimer

Description

@JakobJingleheimer

Version

21.7.1

Platform

Darwin Kernel Version 22.6.0, arm64

Subsystem

test

What steps will reproduce the bug?

$ node --test

Minimal repro: JakobJingleheimer/node-test-broadcastchannel@84b3de2

Minimal repro "fixed": JakobJingleheimer/node-test-broadcastchannel@9997b1e

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

100%

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

node:test should kill the open broadcast channel when the tests finish (this is what every other test runner I know of does, ex vitest).

What do you see instead?

The command hangs indefinitely.

Additional information

This is especially relevant for tests of code that will run in a browser environment, where something like process.on('exit') doesn't exist, and the BroadcastChannel would not be manually closed (like it is in my "fixed" example above).

Metadata

Metadata

Assignees

No one assigned

    Labels

    test_runnerIssues and PRs related to the test runner subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions