fix: use Bun.main to detect compiled binary instead of Bun.isCompiled (#4)

Bun.isCompiled does not exist and always returns undefined, causing
embeddedAssetMap to be null. This makes the server fall back to looking
for web/dist directory, which doesn't exist when running the compiled
binary from a different location.

The correct way to detect a compiled Bun binary is to check if Bun.main
starts with '/$bunfs' (the virtual filesystem path used by compiled binaries).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CherryLover
2025-12-25 15:15:04 +08:00
committed by GitHub
co-authored by Claude Opus 4.5
parent b953391737
commit abe215d5d5
+2 -2
View File
@@ -163,8 +163,8 @@ export async function startWebServer(options: {
jwtSecret: Uint8Array
socketEngine: SocketEngine
}): Promise<BunServer<WebSocketData>> {
const bunRuntime = (globalThis as typeof globalThis & { Bun?: { isCompiled?: boolean } }).Bun
const embeddedAssetMap = bunRuntime?.isCompiled ? await loadEmbeddedAssetMap() : null
const isCompiled = Bun.main?.startsWith('/$bunfs') ?? false
const embeddedAssetMap = isCompiled ? await loadEmbeddedAssetMap() : null
const app = createWebApp({
getSyncEngine: options.getSyncEngine,
getSseManager: options.getSseManager,