fix(basichost): Emit Connected events asynchronously #2027
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is more of a proposal at this point; for additional context, please look at #2026.
I am aware of the discussions in libp2p/go-libp2p-swarm#295 and libp2p/go-libp2p-swarm#104, but I still see that emitting specifically
EvtConnectednessChanged
and specifically on a new connection is reasonable enough, so let me explain:identify
one, which was a source of our doubts initially, also considering @marten-seemann 's recent reasonable complaints about its complexity.Connected
? BecauseDisconnected
is already spawned in a new routine in here.Notifies.Connected
is still possible so that the fix might be moved directly to the swamp code in here.Connected
event seems to be the most prevailing in the libp2p world, and launching them async again may cancel all the original goals. So here we have a classic tradeoff between performance and API safety/hygiene, and it's up to project maintainers to decide what's the best.