You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
browse: acquireServerLock catch block silently swallows non-EEXIST errors, masks real bugs as phantom lock contention #1084
acquireServerLock() in browse/src/cli.ts (lines ~283–307 on current main) uses a bare catch {} on the fs.openSync(lockPath, 'wx') call. The same applies to the inner catch on the holder-PID read.
When ANY error other than EEXIST occurs (permissions, disk full, Bun fs regressions like the one fixed in #599 via cd66fc2f, future Windows quirks, etc.), execution falls through to:
Inner readFileSync(lockPath) → throws (file doesn't exist, or unreadable)
Inner catch → return null
Caller sees null → prints "Another instance is starting the server, waiting..."
15s timeout → "Timed out waiting for another instance to start the server"
The user sees phantom lock contention that has nothing to do with locking.
Real-world consequence
I hit this today on Windows 11, Bun 1.3.10, on a gstack 0.13.2.0 install that happened to sit on commit 247fc3ba (PR #603) instead of cd66fc2f (PR #602 — the #599 fix). Both commits were tagged v0.13.2.0 but sit on divergent paths, and #603's merge appears to have carried the pre-fix cli.ts back in. main HEAD has the correct 'wx' code, but anyone installed at that snapshot gets the buggy version.
Spent ~30 minutes diagnosing through three agents before the root cause landed: same bug as #599, silently re-introduced, and the bare catch mask made it look like a lock problem rather than a Bun syscall failure. If the outer catch had been:
Harden `acquireServerLock()` so only `EEXIST` goes down the holder-PID path. Everything else logs via `console.error` with the error code + path before falling back to `return null`. This:
Preserves current behavior for the common-path "lock is held" case
Surfaces real fs/syscall failures immediately (permissions, disk full, future Bun regressions)
Doesn't change the return type or any callers
Same treatment for the inner catch on the holder-PID read.
Environment
Windows 11 Pro, Bun 1.3.10, Node 20.x, MINGW64 bash
#599 was the specific bug (numeric `O_CREAT|O_EXCL|O_WRONLY` flags on Bun Windows). This issue is about the defensive-coding gap that made #599 and its look-alikes near-invisible to users. Independent of the root cause that motivated it.
@16francej — recommend closing this issue, because #1725 covers the same lock-error report and related races, while current code still masks non-EEXIST failures. It should close only after #1725 lands following its remaining check, with the original reproduction and reporter attribution retained.
Fixed in fork-port wave 2: acquireServerLock no longer swallows non-EEXIST errors — real failures (EACCES, EROFS, ...) surface with the actual error instead of masquerading as phantom lock contention.
Commit: d70e6586 fix(browse): lock acquisition reports real errors instead of phantom contention (#1084)
Pinned by: browse/test/server-lock-errors.test.ts
Activity
fix: surface non-EEXIST errors in acquireServerLock instead of maskin…
jbetala7 commentedon May 26, 2026
Opened PR #1725 with the lock-diagnostic hardening and focused regression coverage: #1725
time-attack commentedon Jul 15, 2026
@16francej — recommend closing this issue, because #1725 covers the same lock-error report and related races, while current code still masks non-EEXIST failures. It should close only after #1725 lands following its remaining check, with the original reproduction and reporter attribution retained.
garrytan commentedon Aug 15, 2026
Fixed in fork-port wave 2:
acquireServerLockno longer swallows non-EEXIST errors — real failures (EACCES, EROFS, ...) surface with the actual error instead of masquerading as phantom lock contention.Commit:
d70e6586fix(browse): lock acquisition reports real errors instead of phantom contention (#1084)Pinned by:
browse/test/server-lock-errors.test.tsShips in #2577 (v1.65.0.0).
v1.65.0.0 feat: fork port wave 2 — feature fixes, session persistence…