Skip to content
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

Refresh ping timers #628

Merged
merged 1 commit into from Nov 1, 2021
Merged

Conversation

Nibbler999
Copy link
Contributor

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behaviour

Ping timers are repeatedly cleared and recreated

New behaviour

Ping timers are refreshed instead which is more efficient

Other information (e.g. related issues)

https://nodejs.org/docs/latest-v10.x/api/timers.html#timers_timeout_refresh

lib/socket.ts Outdated
this.pingIntervalTimer = setTimeout(() => {
debug(
"writing ping packet - expecting pong within %sms",
this.server.opts.pingTimeout
);
this.sendPacket("ping");
this.resetPingTimeout(this.server.opts.pingTimeout);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior is changed here, isn't it? The client would now have up to pingTimeout + pingInterval ms to respond to the ping, instead of pingTimeout ms in the current impl.

@Nibbler999 Nibbler999 marked this pull request as draft October 31, 2021 03:08
@Nibbler999
Copy link
Contributor Author

I'll limit the scope to just pingIntervalTimer for now.

@Nibbler999 Nibbler999 marked this pull request as ready for review October 31, 2021 17:36
@darrachequesne darrachequesne merged commit 37474c7 into socketio:master Nov 1, 2021
@darrachequesne
Copy link
Member

@Nibbler999 thanks a lot 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants