*Check if socket exists before closing to prevent errors on possible race conditions

This commit is contained in:
Derrick Hammer 2022-08-03 22:22:40 -04:00
parent 43041160be
commit 4f21ab970d
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 5 additions and 1 deletions

View File

@ -150,8 +150,12 @@ export class Socket extends EventEmitter {
}
end(): void {
callModule(DHT_MODULE, "socketExists", { id: this.id }).then(([exists]: ErrTuple) => {
if (exists) {
callModule(DHT_MODULE, "close", { id: this.id });
}
});
}
private ensureEvent(event: string): void {
if (!(event in this.eventUpdates)) {