Skip to content

Conversation

@lorenzo-arena
Copy link

When opening a datachannel, the event handler is supposed to use the channel reference to add handlers for channel events. However, if the datachannel open event handler is an async function, its execution is delayed and events could be lost if they happen in the meantime.

We encountered this issue since the application on the other side tried to open multiple channels and immediately started sending messages. While the issue didn't always happen, if a message was sent before having the coroutine handler for the datachannel event executed that message would effectively be lost. Waiting for the event handler completion ensures that we can register the channel event handlers.

When opening a datachannel, the event handler is supposed to
use the channel reference to add handlers for channel events.
However, if the datachannel open event handler is an async function,
its execution is delayed and events could be lost if they happen
in the meantime.
@lorenzo-arena lorenzo-arena force-pushed the await-datachannel-event branch from 209e30c to 06fe5de Compare November 17, 2025 08:29
@jlaine
Copy link
Collaborator

jlaine commented Nov 29, 2025

Could we please have a unit test that captures the condition you are trying to fix?

@jlaine jlaine added the changes requested Some changes are required before the PR can be merged. label Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changes requested Some changes are required before the PR can be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants