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: force-closing local discovery TCP server could always time out #498

Merged
merged 5 commits into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/discovery/local-discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ export class LocalDiscovery extends TypedEmitter {
return
}
}

// Bail if the server has already stopped by this point. This should be
// rare but can happen during connection swaps if the new connection is
// "promoted" after the server's doors have already been closed.
if (!this.#server.listening) {
this.#log('server stopped, destroying connection %h', remotePublicKey)
conn.destroy()
return
}
Comment on lines +230 to +237
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confident1 in my understanding of the problem...less so in my solution. Do we want to do this if the server is not force-closed, for example?

Footnotes

  1. this might be hubris


this.#noiseConnections.set(remoteId, conn)

conn.on('close', () => {
Expand Down
Loading