fix: use named error handler in ws.end() to prevent listener leak

ws.once() wraps the callback, so removeListener with the original
function reference won't match. Switch to ws.on() with a named
onError function so removeListener correctly detaches it after
successful close.
This commit is contained in:
MekayelAnik 2026-04-14 16:11:48 +06:00
parent d71a6408c7
commit 001bb99aa8

View file

@ -352,9 +352,10 @@ export const loadGraphToLbug = async (
Array.from(pairWriteStreams.values()).map(
(ws) =>
new Promise<void>((resolve, reject) => {
ws.once('error', reject);
const onError = (err: Error) => reject(err);
ws.on('error', onError);
ws.end(() => {
ws.removeListener('error', reject);
ws.removeListener('error', onError);
resolve();
});
}),