fix(tui): remove stale readline close listeners to prevent memory leak warning
Clean up the once('close') listener on the readline Interface when
rl.question() resolves normally. Previously, each prompt loop iteration
accumulated a close listener that was never removed, triggering
MaxListenersExceededWarning after 11 prompts.
This commit is contained in:
@@ -151,8 +151,12 @@ export class MinimalTui {
|
|||||||
resolve('');
|
resolve('');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.rl.question(promptText, resolve);
|
const onClose = () => resolve('');
|
||||||
this.rl.once('close', () => resolve(''));
|
this.rl.once('close', onClose);
|
||||||
|
this.rl.question(promptText, (answer) => {
|
||||||
|
this.rl?.removeListener('close', onClose);
|
||||||
|
resolve(answer);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user