From 001bb99aa83b1bae72f57812df6e012a537f8f59 Mon Sep 17 00:00:00 2001 From: MekayelAnik Date: Tue, 14 Apr 2026 16:11:48 +0600 Subject: [PATCH] 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. --- gitnexus/src/core/lbug/lbug-adapter.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gitnexus/src/core/lbug/lbug-adapter.ts b/gitnexus/src/core/lbug/lbug-adapter.ts index 2b8f8772d..164b29b66 100644 --- a/gitnexus/src/core/lbug/lbug-adapter.ts +++ b/gitnexus/src/core/lbug/lbug-adapter.ts @@ -352,9 +352,10 @@ export const loadGraphToLbug = async ( Array.from(pairWriteStreams.values()).map( (ws) => new Promise((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(); }); }),