-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[server] make ping pong async #8348
Conversation
Codecov Report
@@ Coverage Diff @@
## main #8348 +/- ##
===========================================
- Coverage 28.28% 11.17% -17.11%
===========================================
Files 41 18 -23
Lines 3490 993 -2497
===========================================
- Hits 987 111 -876
+ Misses 2447 880 -1567
+ Partials 56 2 -54
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
setPingSent(ws, Date.now()); | ||
ws.ping(); // if this fails it triggers a ws error, and fails the ws anyway | ||
|
||
// note: decoupling by using `setImmediate` in order to offload to the following event loop iteration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -93,7 +101,14 @@ export class WsConnectionHandler implements Disposable { | |||
}); | |||
ws.on('ping', (data: any) => { | |||
// answer browser-side ping to conform RFC6455 (https://tools.ietf.org/html/rfc6455#section-5.5.2) | |||
ws.pong(data); | |||
// note: decoupling by using `setImmediate` in order to offload to the following event loop iteration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code LGTM, tested and works - thx! 🙏
Let's make ping pong less sync.