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:
William Valentin
2026-02-09 21:50:43 -08:00
parent 62331c3a09
commit 322852917c
+6 -2
View File
@@ -151,8 +151,12 @@ export class MinimalTui {
resolve('');
return;
}
this.rl.question(promptText, resolve);
this.rl.once('close', () => resolve(''));
const onClose = () => resolve('');
this.rl.once('close', onClose);
this.rl.question(promptText, (answer) => {
this.rl?.removeListener('close', onClose);
resolve(answer);
});
});
}