-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PeerConnection.close() Method is Blocking the Event Loop #326
Comments
node-datachannel/src/polyfill/RTCDataChannel.ts Lines 192 to 195 in dd3954e
FixI was able to fix the issue by updating the close(): void {
setImmediate(() => {
this.#closeRequested = true;
this.#dataChannel.close();
});
} This change ensures that the @murat-dogan Let me know if this is an ideal solution so i can make a PR. |
Hello @mertushka and thank you for sharing the solution. The only point is, can we keep that part out of setImmediate; What do you think? |
@murat-dogan Done with the #327 PR. |
@murat-dogan Can you release the new version about this? This is considered as a major bug and i must have the fix on my module ASAP. Thanks in advance. |
https://github.com/murat-dogan/node-datachannel/releases/tag/v0.25.0 Has been released. |
@murat-dogan This issue should be reopened as Relevant issue: mertushka/haxball.js#49 |
Describe the Bug
In certain cases, the
PeerConnection.close()
polyfill seems to block the event loop. Profiling has shown that thePeerConnection.close()
method sometimes takes ~1 second to execute instead of the usual few milliseconds.Additionally, the
datachannel.readyState
does not always correctly reflect its real state. This inconsistency can lead to issues such as attempting to send messages on a data channel that appears open but is not actually open. Check the additional context for more insight.To Reproduce
Steps to reproduce the issue:
PeerConnection.close()
call.datachannel.readyState
before and after the.close()
call to confirm state inconsistencies.Expected Behavior
PeerConnection.close()
polyfill should clean up the connection asynchronously and avoid blocking the event loop.datachannel.readyState
should accurately reflect the real state of the data channel.Device Information
Additional Context
See: mertushka/haxball.js#44
The text was updated successfully, but these errors were encountered: