From a1bbc76c12db12bf9c98291cb267f26203d07e35 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sat, 28 Mar 2026 08:11:04 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20browse=20CLI=20Windows=20lockfile=20?= =?UTF-8?q?=E2=80=94=20use=20string=20flag=20instead=20of=20numeric=20cons?= =?UTF-8?q?tants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bun compiled binaries on Windows don't handle numeric fs.constants correctly. The string flag 'wx' is semantically identical to O_CREAT | O_EXCL | O_WRONLY per Node docs and works on all platforms. Fixes #599 Co-Authored-By: Claude Opus 4.6 (1M context) --- browse/src/cli.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/browse/src/cli.ts b/browse/src/cli.ts index a24886c2..e6e470fd 100644 --- a/browse/src/cli.ts +++ b/browse/src/cli.ts @@ -291,8 +291,9 @@ async function startServer(extraEnv?: Record): Promise void) | null { const lockPath = `${config.stateFile}.lock`; try { - // O_CREAT | O_EXCL — fails if file already exists (atomic check-and-create) - const fd = fs.openSync(lockPath, fs.constants.O_CREAT | fs.constants.O_EXCL | fs.constants.O_WRONLY); + // 'wx' — create exclusively, fails if file already exists (atomic check-and-create) + // Using string flag instead of numeric constants for Bun Windows compatibility + const fd = fs.openSync(lockPath, 'wx'); fs.writeSync(fd, `${process.pid}\n`); fs.closeSync(fd); return () => { try { fs.unlinkSync(lockPath); } catch {} };