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

fix: ensure to check for Infinity in checkMaxLimit function #1666

Conversation

SgtPooki
Copy link
Member

@SgtPooki SgtPooki commented Mar 31, 2023

fixes #1665

@maschad maschad changed the title fix(checkMaxLimit): correct limit log msg 'x of NaN' fix: Ensure to check for infinity in checkMaxLimit Apr 1, 2023
Copy link
Member

@maschad maschad left a comment

Choose a reason for hiding this comment

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

Thanks!

@maschad maschad changed the title fix: Ensure to check for infinity in checkMaxLimit fix: ensure to check for Infinity in checkMaxLimit function Apr 1, 2023
@SgtPooki
Copy link
Member Author

SgtPooki commented Apr 1, 2023

note @maschad that we could also change this to !Number.isSafeNumber(value) which would catch both NaN and Infinity, but tbh, we should be catching NaN elsewhere. I think the NaN displaying in #1665 is something with @libp2p/logger or debug

@maschad
Copy link
Member

maschad commented Apr 2, 2023

Agreed @SgtPooki I think this more explicit handling is more appropriate to see the flow of execution.

@achingbrain
Copy link
Member

Related: #1573

@maschad maschad merged commit 00a7783 into master Apr 3, 2023
@maschad maschad deleted the 1665-bugconnection-manager-checkmaxlimit-unsetinvalid-limit-not-caught-properly branch April 3, 2023 14:44
@achingbrain
Copy link
Member

achingbrain commented Apr 3, 2023

What's the problem this solves?

If the limit is Infinity and the check is if (value > limit) {, value will never be over limit so this._pruneConnections will never be called.

Or is it just to tidy up the log?

@SgtPooki
Copy link
Member Author

SgtPooki commented Apr 7, 2023

Mostly to tidy up the log.

I saw these errors as a red herring of something else, found out limit was set to infinity but the log confused me.

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.

bug(connection-manager): checkMaxLimit - unset/invalid limit not caught properly
3 participants