@holin-work/holin-cli 1.3.7 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/holin-cli.js +20 -2
- package/package.json +1 -1
package/bin/holin-cli.js
CHANGED
|
@@ -34,6 +34,7 @@ const CONFIG_DIR = join(
|
|
|
34
34
|
const CREDENTIALS_FILE = join(CONFIG_DIR, "credentials.json");
|
|
35
35
|
const PID_FILE = join(CONFIG_DIR, "proxy.pid");
|
|
36
36
|
const LOG_FILE = join(CONFIG_DIR, "proxy.log");
|
|
37
|
+
const LOGIN_LOCK_FILE = join(CONFIG_DIR, "login.lock"); // written by auth login, read by proxy healthcheck
|
|
37
38
|
|
|
38
39
|
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
39
40
|
|
|
@@ -389,6 +390,14 @@ async function cmdAuthLogin() {
|
|
|
389
390
|
process.exit(1);
|
|
390
391
|
}
|
|
391
392
|
|
|
393
|
+
// Write login lock so the running proxy does not exit during re-auth credential gap.
|
|
394
|
+
ensureConfigDir();
|
|
395
|
+
writeFileSync(LOGIN_LOCK_FILE, String(process.pid), "utf-8");
|
|
396
|
+
const removeLock = () => { try { if (existsSync(LOGIN_LOCK_FILE)) unlinkSync(LOGIN_LOCK_FILE); } catch {} };
|
|
397
|
+
process.on("exit", removeLock);
|
|
398
|
+
process.on("SIGINT", () => { removeLock(); process.exit(1); });
|
|
399
|
+
process.on("SIGTERM", () => { removeLock(); process.exit(1); });
|
|
400
|
+
|
|
392
401
|
console.log("[holin-cli] Verifying API Key...");
|
|
393
402
|
let result;
|
|
394
403
|
try {
|
|
@@ -431,6 +440,7 @@ async function cmdAuthLogin() {
|
|
|
431
440
|
console.error(`[holin-cli] Warning: Failed to start local proxy — ${err.message}`);
|
|
432
441
|
console.error("[holin-cli] You can start it manually with: holin-cli proxy start");
|
|
433
442
|
}
|
|
443
|
+
// Lock removed automatically via process.on("exit")
|
|
434
444
|
}
|
|
435
445
|
|
|
436
446
|
function cmdAuthLogout() {
|
|
@@ -529,12 +539,20 @@ function cmdProxyStart() {
|
|
|
529
539
|
return;
|
|
530
540
|
}
|
|
531
541
|
// Check if credentials file still exists (user may have logged out / uninstalled)
|
|
532
|
-
// Use a 30s grace period to avoid false positives during re-auth (old creds cleared, new ones not yet written)
|
|
542
|
+
// Use a 30s grace period to avoid false positives during re-auth (old creds cleared, new ones not yet written).
|
|
543
|
+
// Skip the grace period countdown entirely while a login.lock file exists — auth login is in progress.
|
|
533
544
|
const credsExist = existsSync(CREDENTIALS_FILE);
|
|
534
545
|
const creds = credsExist ? readCredentials() : null;
|
|
535
546
|
const hasValidKey = !!(creds?.api_key);
|
|
536
547
|
if (!hasValidKey) {
|
|
537
|
-
|
|
548
|
+
const loginInProgress = existsSync(LOGIN_LOCK_FILE);
|
|
549
|
+
if (loginInProgress) {
|
|
550
|
+
// auth login is actively running — reset timer, do not start grace period
|
|
551
|
+
if (credsMissingSince) {
|
|
552
|
+
log("[proxy] Login lock detected, resetting credentials grace period.");
|
|
553
|
+
credsMissingSince = null;
|
|
554
|
+
}
|
|
555
|
+
} else if (!credsMissingSince) {
|
|
538
556
|
credsMissingSince = Date.now();
|
|
539
557
|
log("[proxy] Credentials missing, starting 30s grace period...");
|
|
540
558
|
} else if (Date.now() - credsMissingSince > 30000) {
|