mirror of https://github.com/garrytan/gstack.git
Merge 1d430ca471 into a3259400a3
This commit is contained in:
commit
42ee1b8ec0
|
|
@ -385,7 +385,12 @@ function acquireServerLock(): (() => void) | null {
|
|||
fs.writeSync(fd, `${process.pid}\n`);
|
||||
fs.closeSync(fd);
|
||||
return () => { safeUnlink(lockPath); };
|
||||
} catch {
|
||||
} catch (err: any) {
|
||||
if (err?.code !== 'EEXIST') {
|
||||
// Unexpected error — surface it rather than masking as phantom lock contention
|
||||
console.error(`[browse] acquireServerLock: unexpected ${err?.code || ''} opening ${lockPath}: ${err?.message}`);
|
||||
return null;
|
||||
}
|
||||
// Lock already held — check if the holder is still alive
|
||||
try {
|
||||
const holderPid = parseInt(fs.readFileSync(lockPath, 'utf8').trim(), 10);
|
||||
|
|
@ -395,7 +400,8 @@ function acquireServerLock(): (() => void) | null {
|
|||
// Stale lock — remove and retry
|
||||
fs.unlinkSync(lockPath);
|
||||
return acquireServerLock();
|
||||
} catch {
|
||||
} catch (err: any) {
|
||||
console.error(`[browse] acquireServerLock: stale-lock read failed: ${err?.message}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue