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

Bugfix: server lifecycle when closing during listen #155

Merged
merged 3 commits into from
Jan 2, 2024

Conversation

HDegroote
Copy link
Contributor

This fixes a catastrophic bug when destroying a server while listen() is being called, but before the server added itself to the DHT's server-set. This resulted in the _background

async _background () {
function of the announcer entering an infinite loop hogging the event loop due to continuously throwing and catching DHT_CLOSED errors. To reproduce, you can run the newly added test on the original code.

The fix is to add the server to the DHT's server-set as soon as listen() is called, ensuring its close function is always called when the DHT gets destroyed.

If there originally was a reason not to do immediately add a new server to the DHT's server-set, I can instead look into reworking the lifecycle a bit more in depth.

@mafintosh mafintosh merged commit 5350885 into main Jan 2, 2024
4 checks passed
@mafintosh mafintosh deleted the bugfix-server-lifecycle branch January 2, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants