Skip to content

Add test coverage & clean up handshakes received when suspended & reorder clearing - #285

Open
lejeunerenard wants to merge 6 commits into
mainfrom
server-mem-leak-investigation
Open

Add test coverage & clean up handshakes received when suspended & reorder clearing#285
lejeunerenard wants to merge 6 commits into
mainfrom
server-mem-leak-investigation

Conversation

@lejeunerenard

Copy link
Copy Markdown
Contributor

This PR came from explorations around potential memory leaks. It includes the following:

  1. Added a test for guard against peer flooding a server with handshakes messages. Test called peer cant flood w/ handshakes
  2. Reorder deleting ._connects.delete(k) to before clearing holepunch entry.
    Not required but is clearer that it always is cleared now and that a holepunch entry missing can't leak _connects though it was never observed to do so.
  3. Add test & protect against leaking _holepunches entries when received during closing or being suspended. Test called handshakes that arrive while the server is suspended are cleared

_clear deletes the _connects entry even when the slot was reused credited to @HDegroote for writing.

Guard already exists and the test shows it works.
How this could happen has not been reproduced yet, but it is safe change
as any `hs` that gets cleared should ensure the noise key entry in
`_connects` is cleared regardless of the `_holepunches` entry.

Test by @HDegroote
@lejeunerenard
lejeunerenard requested review from a team and mafintosh August 12, 2026 19:50
mafintosh
mafintosh previously approved these changes Aug 12, 2026
Comment thread lib/server.js Outdated
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.

2 participants