Closed HDegroote closed 10 months ago
The race condition triggered when server.listen() created the announcer https://github.com/holepunchto/hyperdht/blob/75059f561f633ab7f7cde214a6f7ed309f503bcb/lib/server.js#L111-L116
server.listen()
after server.close() started executing but before await this.dht.bind()resolved, because then this._listening is not yet true, andclose() early returns if no listener is found: https://github.com/holepunchto/hyperdht/blob/75059f561f633ab7f7cde214a6f7ed309f503bcb/lib/server.js#L83-L86
server.close()
await this.dht.bind()
this._listening
close()
It's a catastrophic bug when it triggers, because an endless loop floods the CPU in Announcer._background(): https://github.com/holepunchto/hyperdht/blob/75059f561f633ab7f7cde214a6f7ed309f503bcb/lib/announcer.js#L96-L97 It will continuously throw NODE_DESTROYED errors which are caught and ignored
Announcer._background()
NODE_DESTROYED
The race condition triggered when
server.listen()
created the announcer https://github.com/holepunchto/hyperdht/blob/75059f561f633ab7f7cde214a6f7ed309f503bcb/lib/server.js#L111-L116after
server.close()
started executing but beforeawait this.dht.bind()
resolved, because thenthis._listening
is not yet true, andclose()
early returns if no listener is found: https://github.com/holepunchto/hyperdht/blob/75059f561f633ab7f7cde214a6f7ed309f503bcb/lib/server.js#L83-L86It's a catastrophic bug when it triggers, because an endless loop floods the CPU in
Announcer._background()
: https://github.com/holepunchto/hyperdht/blob/75059f561f633ab7f7cde214a6f7ed309f503bcb/lib/announcer.js#L96-L97 It will continuously throwNODE_DESTROYED
errors which are caught and ignored