You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RunAndListenClient: multiple goroutines across multiple runs of RunAndListenClient are reading from the “done” channel, and which one will receive something from that channel – completely random. As a result, in case of a lost connection, some random goroutine will exit and its graceful shutdown functionality will be lost.
Solution
To avoid such problems, the code should be simple. It’s hard to figure out how this method works because of multiple goroutines
and channels, thus it’s more error-prone. The easier the code, the harder a bug to find a place to hide. This functionality across all the methods and their goroutines can be done with a single context passed from the main. All the goroutines will read from ctx.Done() in select to shutdown gracefully.
The text was updated successfully, but these errors were encountered:
Problem
RunAndListenClient: multiple goroutines across multiple runs of RunAndListenClient are reading from the “done” channel, and which one will receive something from that channel – completely random. As a result, in case of a lost connection, some random goroutine will exit and its graceful shutdown functionality will be lost.
Solution
To avoid such problems, the code should be simple. It’s hard to figure out how this method works because of multiple goroutines
and channels, thus it’s more error-prone. The easier the code, the harder a bug to find a place to hide. This functionality across all the methods and their goroutines can be done with a single context passed from the main. All the goroutines will read from ctx.Done() in select to shutdown gracefully.
The text was updated successfully, but these errors were encountered: