libp2p/hydra-booster

Always select on a context when writing to a channel that could block

Stebalien opened this issue · 1 comments

If you write to a channel that and you think the receiver might not read from it (e.g., the receiver could cancel the request), make sure to select on a channel. Grep the codebase for <- and audit all the channel writes that don't select on contexts.

Note to whoever picks this up:

As far as I can tell, the only place this could hurt us in production is in bootstrap channel returned by NewSybil (used to indicate bootstrap status/completion). Basically if we stop the node before bootstrapping has completed then that goroutine will not exit.

The other place is in the UI, where we write metrics we receive periodically to a channel. Howveer UI is disabled in production so not a huge concern.