Merge branch 'fix-mem-leak' into 'main'

Fix memory leak in relay?

See merge request soapbox-pub/ditto!726
This commit is contained in:
Alex Gleason 2025-03-19 20:20:13 +00:00
commit fab34dbf5b

View file

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