fix(cli): harden election edge cases
This commit is contained in:
parent
68c62774ac
commit
c61e93a1f3
2 changed files with 12 additions and 7 deletions
|
|
@ -164,11 +164,12 @@ export namespace EffectFlock {
|
|||
process.kill(owner.pid, 0)
|
||||
return true
|
||||
},
|
||||
catch: (cause) => {
|
||||
const code = cause && typeof cause === "object" && "code" in cause ? cause.code : undefined
|
||||
return code !== "ESRCH"
|
||||
},
|
||||
}).pipe(Effect.orElseSucceed(() => false))
|
||||
catch: (cause) => (cause && typeof cause === "object" && "code" in cause ? cause.code : undefined),
|
||||
}).pipe(
|
||||
// Only ESRCH proves the pid is gone; other errors (e.g. EPERM) mean a
|
||||
// process exists, so never break a possibly live owner's lock.
|
||||
Effect.catch((code) => Effect.succeed(code !== "ESRCH")),
|
||||
)
|
||||
if (!alive) return true
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue