mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-21 12:18:24 +08:00
fix: browse CLI Windows lockfile — use string flag instead of numeric constants
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) <noreply@anthropic.com>
This commit is contained in:
@@ -291,8 +291,9 @@ async function startServer(extraEnv?: Record<string, string>): Promise<ServerSta
|
|||||||
function acquireServerLock(): (() => void) | null {
|
function acquireServerLock(): (() => void) | null {
|
||||||
const lockPath = `${config.stateFile}.lock`;
|
const lockPath = `${config.stateFile}.lock`;
|
||||||
try {
|
try {
|
||||||
// O_CREAT | O_EXCL — fails if file already exists (atomic check-and-create)
|
// 'wx' — create exclusively, 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);
|
// Using string flag instead of numeric constants for Bun Windows compatibility
|
||||||
|
const fd = fs.openSync(lockPath, 'wx');
|
||||||
fs.writeSync(fd, `${process.pid}\n`);
|
fs.writeSync(fd, `${process.pid}\n`);
|
||||||
fs.closeSync(fd);
|
fs.closeSync(fd);
|
||||||
return () => { try { fs.unlinkSync(lockPath); } catch {} };
|
return () => { try { fs.unlinkSync(lockPath); } catch {} };
|
||||||
|
|||||||
Reference in New Issue
Block a user