-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
ws.terminate() fires the 'close' event 30 secs after termination? #891
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
Comments
In the worst case scenario the Upon receiving this event the other peer closes the connection and this make the same
I agree that this seems cumbersome and unnecessary, especially because |
Ok, thank you for your answer @lpinca ! I'm working in an environment where clients rarely gracefully disconnects (they power off), so I'm in the worst case scenario most of the time :) I've moved to a different library. So feel free to close/discard this issue, if the current implementation is as intended. |
I guess you were using If so I totally understand your use case. |
Yes exactly. |
When
ws.terminate()
(WebSocket.prototype.terminate
) is called, the connection is immediately ended, yetcleanupWebsocketResources
is called with a timeout of 30 seconds (a time hardcoded forcloseTimeout
)?cleanupWebsocketResources
emits the'close'
event. So terminating a connection, with eventHandlers registered for the'close'
event, will then trigger these 30 sec after termination.Is this intentional? If so, why?
If there is something I have misinterpreted/misunderstood, please enlighten me (is
terminate
only supposed to be called internally? In that case, why expose it onWebSocket
?) - to me it seems weird that:A connection that is forcefully terminated waits to clean up, and more importantly, waits to fire the
'close'
event as part of the awaited cleanup.For convenience, here is the code I am referring to, at the time of writing:
Hardcoded timeout :
WebSocket.prototype.terminate :
cleanupWebsocketResources (this.emit('close', ...) is called):
The text was updated successfully, but these errors were encountered: