fix(cliproxy): prevent race in promptNickname close handler

This commit is contained in:
kaitranntt
2026-01-06 13:52:14 -05:00
parent 5970e70e26
commit 107e2813f9
+10 -2
View File
@@ -76,8 +76,15 @@ async function promptNickname(
}
return new Promise<string | null>((resolve) => {
// Handle Ctrl+C gracefully
rl.on('close', () => resolve(null));
let resolved = false;
// Handle Ctrl+C gracefully (only if not already resolved)
rl.on('close', () => {
if (!resolved) {
resolved = true;
resolve(null);
}
});
const askForNickname = () => {
rl.question('[?] Enter a nickname for this account: ', (answer) => {
@@ -102,6 +109,7 @@ async function promptNickname(
return;
}
resolved = true;
rl.close();
resolve(nickname);
});