Skip to content

Release session requests from the congestion window once - #133

Merged
mafintosh merged 1 commit into
holepunchto:mainfrom
JayOfTheKeyboard:fix/session-destroy-double-congestion-recv
Oct 27, 2026
Merged

mafintosh merged 1 commit into
holepunchto:mainfrom
JayOfTheKeyboard:fix/session-destroy-double-congestion-recv

Conversation

@JayOfTheKeyboard

Copy link
Copy Markdown
Contributor

Session.destroy credits the congestion window twice for each request it destroys.

#78 added this.dht.io.congestion.recv() to Session.destroy so that unanswered session requests stop counting as congestion. Since ba369da, Request.destroy calls this._io.congestion.recv() itself, so the session path now does it twice. The window then under-counts what is in flight. With three session requests and one unrelated request in flight in the same slot, destroying the session leaves _total at 0 while the other request is still outstanding, so each destroyed session request can let one extra request out before isFull() trips.

This removes the call from Session.destroy, leaving Request.destroy as the one place a destroyed request is released.

The new test sends one request and three session requests to a node that never replies, destroys the session, and checks the window still counts the remaining request. On main it fails with actual: 0, expected: 1, and it passes with the change (20 of 20 runs). npm run lint is unchanged (same 10 warnings as main), and npm run test:node and npm run test:bare (Bare 1.34.1) pass, 53/53.

Session.destroy called congestion.recv() before req.destroy(), which has
also called it since ba369da. Each destroyed session request was
credited twice, so the window under-counted what is in flight.
@JayOfTheKeyboard
JayOfTheKeyboard requested a review from a team October 5, 2026 05:08
@JayOfTheKeyboard

Copy link
Copy Markdown
Contributor Author

Hi, friendly ping on this. It still merges cleanly. Let me know if you'd like any changes.

@mafintosh

Copy link
Copy Markdown
Contributor

nice catch

@mafintosh
mafintosh merged commit da37cbb into holepunchto:main Oct 27, 2026
5 checks passed
JayOfTheKeyboard added a commit to JayOfTheKeyboard/JayOfTheKeyboard that referenced this pull request Oct 27, 2026
@JayOfTheKeyboard

Copy link
Copy Markdown
Contributor Author

Thanks!

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