mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-02 18:18:43 +00:00
fix(cliproxy): prevent race in promptNickname close handler
This commit is contained in:
@@ -76,8 +76,15 @@ async function promptNickname(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new Promise<string | null>((resolve) => {
|
return new Promise<string | null>((resolve) => {
|
||||||
// Handle Ctrl+C gracefully
|
let resolved = false;
|
||||||
rl.on('close', () => resolve(null));
|
|
||||||
|
// Handle Ctrl+C gracefully (only if not already resolved)
|
||||||
|
rl.on('close', () => {
|
||||||
|
if (!resolved) {
|
||||||
|
resolved = true;
|
||||||
|
resolve(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const askForNickname = () => {
|
const askForNickname = () => {
|
||||||
rl.question('[?] Enter a nickname for this account: ', (answer) => {
|
rl.question('[?] Enter a nickname for this account: ', (answer) => {
|
||||||
@@ -102,6 +109,7 @@ async function promptNickname(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolved = true;
|
||||||
rl.close();
|
rl.close();
|
||||||
resolve(nickname);
|
resolve(nickname);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user