Skip to content

fix(cli): stale-lock cleanup race in acquireOnboardLock #1281

@ericksoa

Description

@ericksoa

Bug

In src/lib/onboard-session.ts, acquireOnboardLock detects a stale lock (dead PID) and calls fs.unlinkSync(LOCK_FILE) before recreating it. Two concurrent processes can both read the same stale file, and the slower one can unlink the fresh lock the faster one just created, then win on its next retry. This breaks mutual exclusion.

Fix

Use an atomic stale-claim approach: write a temp file, then fs.linkSync(tempPath, LOCK_FILE) (succeeds only if LOCK_FILE doesn't exist). Only remove stale files after successfully claiming the lock.

Found by

CodeRabbit review on #1272. Pre-existing from original JS.

Metadata

Metadata

Assignees

Labels

NemoClaw CLIUse this label to identify issues with the NemoClaw command-line interface (CLI).bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions