nim-libp2p icon indicating copy to clipboard operation
nim-libp2p copied to clipboard

Connection closure in handler

Open arnetheduck opened this issue 1 year ago • 0 comments

In protocol handlers, there's a zoo of options with regards to closing the stream after handling the protocol request:

Multistream closes the connection after the handling is done, so it seems like closing is redundant / not needed but if that's the case, at least the example should be updated, but probably also all existing handlers, so they behave the same - the semantic difference to capture here is whether closing should be a fire-and-forget option or whether we want to wait for a graceful two-sided shutdown - if we close in multistream, the handler has no way of knowing if the other side closed gracefully.

A complication is of course is what to do when an exception is raised and partial data has been written - typically, it should be expected that handlers handle their exceptions also, but it so turns out that multistream swallows all exceptions silently potentially leading to undetected problems.

arnetheduck avatar Sep 05 '22 20:09 arnetheduck