mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-14 23:22:54 +00:00
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:
parent
d71a6408c7
commit
001bb99aa8
1 changed files with 3 additions and 2 deletions
|
|
@ -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();
|
||||
});
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue