Skip to content

fix(sim-cli): take over a stale source lock whose owner file was left empty or cut short - #10300

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/sim-cli-lock-malformed-owner
Nov 21, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/sim-cli-lock-malformed-owner

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

isStaleLock read the source directory lock's owner.json with .then((text) => JSON.parse(text), () => null). A rejection handler in the same .then never sees an error thrown by the success callback, so a malformed owner file threw a raw SyntaxError:

  • Dead command: if a command died between writeFile creating owner.json and filling it, every later source command in that directory crashed. None of them reached the 60-second rule for a lock with no recorded owner, and the "remove .sim/command.lock" hint never showed.
  • Mid-write read: a command that read the file while another was writing it crashed in the same way, instead of being refused as busy (SOURCE_DIR_BUSY, exit 10).

A malformed owner now counts as unrecorded, so the age rule decides. A stale lock is taken over; a fresh one is busy.

This came up as a Greptile finding on #10299.

Testing

  • The existing "died before recording its owner" test is now a table with three rows: no owner file, an empty file, and a cut-short file.
  • New test: a fresh lock whose owner file is empty is refused as busy and is not taken over.
  • On the previous code, the empty and cut-short rows and the busy test all fail, with SyntaxError.
  • sim-cli: 1056 tests pass. tsc, biome, check:comment-hygiene and check:test-patterns pass.

… empty or cut short

isStaleLock read owner.json with .then(JSON.parse, () => null), whose rejection handler never sees a throw from JSON.parse. A command that died between writeFile creating owner.json and filling it left a lock every later command crashed on with a raw SyntaxError, never reaching the age rule; a command reading the file mid-write crashed the same way instead of being refused as busy. A malformed owner now counts as unrecorded, so the 60-second age rule decides.
@vercel

vercel Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 21, 2026 11:11pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Makes isStaleLock treat invalid JSON in owner.json as an unrecorded owner instead of throwing.

  • Source commands can recover locks with incomplete owner files.

Reviews (1) · Last reviewed commit: "fix(sim-cli): take over a stale source l..." · Reviewed by Greptile

@waleedlatif1
waleedlatif1 merged commit 976e3c3 into staging Nov 21, 2026
153 of 155 checks passed

This branch was previously deployed

1 inactive deployment
Preview — a0e91e48 Deployed Nov 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant