Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RunAndListenClient #34

Open
dsha256 opened this issue May 14, 2023 · 0 comments
Open

Fix RunAndListenClient #34

dsha256 opened this issue May 14, 2023 · 0 comments
Assignees
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@dsha256
Copy link
Owner

dsha256 commented May 14, 2023

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.

@dsha256 dsha256 self-assigned this May 14, 2023
@dsha256 dsha256 converted this from a draft issue May 14, 2023
@dsha256 dsha256 added bug Something isn't working wontfix This will not be worked on labels May 14, 2023
@dsha256 dsha256 changed the title Bug: RunAndListenClient Fix RunAndListenClient May 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
Status: Todo
Development

No branches or pull requests

1 participant