Fix memory leak in relay?

This commit is contained in:
Alex Gleason 2025-03-19 15:15:44 -05:00
parent 497b02002e
commit 8fc0092150
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -171,6 +171,10 @@ function connectStream(socket: WebSocket, ip: string | undefined, opts: ConnectS
} else {
const [verb, , ...rest] = msg;
send([verb, subId, ...rest] as NostrRelayMsg);
if (verb === 'CLOSED') {
break;
}
}
}
} catch (e) {
@ -182,6 +186,7 @@ function connectStream(socket: WebSocket, ip: string | undefined, opts: ConnectS
send(['CLOSED', subId, 'error: something went wrong']);
}
} finally {
controllers.get(subId)?.abort();
controllers.delete(subId);
}
}