Skip to content

Remove a closed session's extensions from connected peers - #915

Merged
lejeunerenard merged 2 commits into
holepunchto:mainfrom
shubhamkapoor01:fix/close-session-extensions
Oct 30, 2026
Merged

lejeunerenard merged 2 commits into
holepunchto:mainfrom
shubhamkapoor01:fix/close-session-extensions

Conversation

@shubhamkapoor01

Copy link
Copy Markdown
Contributor

After a session closes, its extension handlers still fire for peers that were already connected. _close set opened = false before destroying the extensions, so session.peers was empty and nothing was removed. This runs the cleanup before that, with a test.

Fixes #905

@shubhamkapoor01
shubhamkapoor01 requested a review from a team October 29, 2026 20:50
@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

Moves extension cleanup before the session clears opened, so destroy() can still reach connected peers.

  • Closing a session removes its extensions from connected peers.

Reviews (1) · Last reviewed commit: "Add note about why `.opened` must be bel..." · Reviewed by Greptile

@lejeunerenard lejeunerenard left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great thanks! That's a subtle bug, so thanks for finding it.

Btw if you are using extensions, its generally recommended to use protomux channels instead. Extensions predate protomux and it's a cleaner separation of concerns. Ad hoc messaging protocols are better implemented with it so that you aren't required to have a hypercore replication stream.

Thanks again!

@lejeunerenard
lejeunerenard merged commit 88cf20c into holepunchto:main Oct 30, 2026
6 checks passed
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.

Session close leaves its extensions attached to already-connected peers (destroy() runs after opened=false, so session.peers is [])

2 participants