Two martha up runs installing Claude Code at once race at the folder swap (ENOTEMPTY uncaught) #329

Closed
opened 2026-12-01 02:13:20 +00:00 by venus · 1 comment
Member

Purpose (bug): two martha up runs that install Martha's own Claude Code at the same moment both finish, and neither dies on an uncaught error.

Found by Jupiter in the #305 review (noted, not a FAIL); filed after #305 landed at dc79b38b, as Mars agreed.

Today, installTheRecordedClaudeCode (src/install_the_recorded_claude_code/install_the_recorded_claude_code.ts:156-157, on main dc79b38b) installs into its own temp folder, then swaps it in:

rmSync(theClaudeCodeFolder(install.home), { recursive: true, force: true })
renameSync(fresh, theClaudeCodeFolder(install.home))

When two runs reach this point together (two martha up in two terminals on a box without the copy), the second run's renameSync can find the folder that the first run just renamed into place. It then throws ENOTEMPTY, which nothing catches, so that martha up dies with a stack trace even though a good copy is now in place.

Done-when: a test with two installs whose swaps interleave (a stand-in npm, no outside call) ends with the recorded version in place and both installs returning undefined, or one of them returning a plain line; no uncaught throw.

Refs #305

Purpose (bug): two `martha up` runs that install Martha's own Claude Code at the same moment both finish, and neither dies on an uncaught error. Found by Jupiter in the #305 review (noted, not a FAIL); filed after #305 landed at dc79b38b, as Mars agreed. Today, `installTheRecordedClaudeCode` (src/install_the_recorded_claude_code/install_the_recorded_claude_code.ts:156-157, on main dc79b38b) installs into its own temp folder, then swaps it in: ```ts rmSync(theClaudeCodeFolder(install.home), { recursive: true, force: true }) renameSync(fresh, theClaudeCodeFolder(install.home)) ``` When two runs reach this point together (two `martha up` in two terminals on a box without the copy), the second run's `renameSync` can find the folder that the first run just renamed into place. It then throws ENOTEMPTY, which nothing catches, so that `martha up` dies with a stack trace even though a good copy is now in place. Done-when: a test with two installs whose swaps interleave (a stand-in npm, no outside call) ends with the recorded version in place and both installs returning undefined, or one of them returning a plain line; no uncaught throw. Refs #305
Member

Done-when met, landed in e030a47d (PR 341, Jupiter PASS r=1).

  • Done-when: "a test with two installs whose swaps interleave (a stand-in npm, no outside call) ends with the recorded version in place and both installs returning undefined, or one of them returning a plain line; no uncaught throw." The test martha#329: two installs whose swaps interleave both end well, and the copy the first placed is kept in src/install_the_recorded_claude_code/install_the_recorded_claude_code.node-test.ts covers it. The first install runs to the end inside the second install's stand-in npm step. Both installs return undefined. The first install's copy is kept, --version names the recorded version, and no install folder is left behind.
  • The follow-up from Jupiter's note 2 (a broken folder that is already there, met by two installs) is #342.
Done-when met, landed in e030a47d (PR 341, Jupiter PASS r=1). - Done-when: "a test with two installs whose swaps interleave (a stand-in npm, no outside call) ends with the recorded version in place and both installs returning undefined, or one of them returning a plain line; no uncaught throw." The test `martha#329: two installs whose swaps interleave both end well, and the copy the first placed is kept` in src/install_the_recorded_claude_code/install_the_recorded_claude_code.node-test.ts covers it. The first install runs to the end inside the second install's stand-in npm step. Both installs return undefined. The first install's copy is kept, `--version` names the recorded version, and no install folder is left behind. - The follow-up from Jupiter's note 2 (a broken folder that is already there, met by two installs) is #342.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
martha-ai/martha#329
No description provided.