Bug: Concurrent pi processes crash on startup — lockSync with zero retries on global settings/auth #1629
joelreymont
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Bug
When multiple
piprocesses start simultaneously (e.g. spawned by a subagent extension for parallel task execution), the second process crashes with:followed by:
The process exits with a non-zero code and produces no useful output.
Root Cause
Both
settings-manager.jsandauth-storage.jsuseproper-lockfile'slockSync()with zero retries during startup:proper-lockfiledefaults toretries: 0forlockSync, so if anotherpiprocess holds the lock (even briefly, during its own startup read), the call throws immediately.Notably,
auth-storage.jsalready has an asyncwithLockAsync()method (line 63) that uses retries with exponential backoff — but the syncwithLock()path (used during startup) does not.Reproduction
With a 2-second delay between launches, both succeed:
Suggested Fix
Add retries to the
lockSynccalls in both files, matching the pattern already used inwithLockAsync:Current Workaround
In our subagent extension, we serialize process launches with an in-process mutex (
LaunchGate) that acquires beforespawn()and releases on first stdout data (indicating the child is past the lock-contention startup phase). This handles the single-parent case but not cross-instance contention.Environment
proper-lockfile^4.1.2Beta Was this translation helpful? Give feedback.
All reactions