fix(#2855): tmux health check fails across module instances in same process
The server-health module used module-level state for inProcessServerRunning, which doesn't survive when Bun loads separate module instances in the same process. Fix: use globalThis with Symbol.for key so the flag is truly process-global. - server-health.ts: replace module-level boolean with globalThis[Symbol.for()] - export markServerRunningInProcess from tmux-utils barrel - test: verify flag skips HTTP fetch, verify globalThis persistence
This commit is contained in:
@@ -1,17 +1,22 @@
|
||||
let serverAvailable: boolean | null = null
|
||||
let serverCheckUrl: string | null = null
|
||||
let inProcessServerRunning = false
|
||||
|
||||
const SERVER_RUNNING_KEY = Symbol.for("oh-my-opencode:server-running-in-process")
|
||||
|
||||
function delay(milliseconds: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, milliseconds))
|
||||
}
|
||||
|
||||
export function markServerRunningInProcess(): void {
|
||||
inProcessServerRunning = true
|
||||
;(globalThis as Record<symbol, boolean>)[SERVER_RUNNING_KEY] = true
|
||||
}
|
||||
|
||||
function isMarkedRunningInProcess(): boolean {
|
||||
return (globalThis as Record<symbol, boolean>)[SERVER_RUNNING_KEY] === true
|
||||
}
|
||||
|
||||
export async function isServerRunning(serverUrl: string): Promise<boolean> {
|
||||
if (inProcessServerRunning) {
|
||||
if (isMarkedRunningInProcess()) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user