Skip to content

Fix RunAndListenClient #34

@dsha256

Description

@dsha256

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwontfixThis will not be worked on

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions