fix: resolve compiled binary crashes from circular dep and Bun CJS splitting bug

This commit is contained in:
LukeParkerDev
2026-04-20 16:19:44 +10:00
parent ce209e22a2
commit 2b3d027e3b
3 changed files with 8 additions and 3 deletions

View File

@@ -13,7 +13,8 @@ import { Installation } from "../../installation"
import { PushRelay } from "../../server/push-relay"
import { Log } from "../../util"
import { Global } from "../../global"
import * as QRCode from "qrcode"
// dynamic import: static `import * as` of CJS package triggers Bun bundler splitting bug
import type * as QRCodeType from "qrcode"
const log = Log.create({ service: "serve" })
@@ -184,6 +185,7 @@ async function printPairQR(pair: PairPayload) {
linkLength: link.length,
qr: qrConfig,
})
const QRCode: typeof QRCodeType = await import("qrcode")
const code = await QRCode.toString(link, {
...qrConfig,
})

View File

@@ -17,7 +17,8 @@ import { errors } from "../../error"
import { lazy } from "@/util/lazy"
import { Effect, Option } from "effect"
import { PushRelay } from "../../push-relay"
import * as QRCode from "qrcode"
// dynamic import: static `import * as` of CJS package triggers Bun bundler splitting bug
import type * as QRCodeType from "qrcode"
import { Agent } from "@/agent/agent"
import { jsonRequest, runRequest } from "./trace"
@@ -60,6 +61,7 @@ function pushPairLink(input: { relaySecret: string; hosts: string[] }) {
}
async function pushPairQRCode(input: { relaySecret: string; hosts: string[] }) {
const QRCode: typeof QRCodeType = await import("qrcode")
return QRCode.toDataURL(pushPairLink(input), pushPairQROptions)
}

View File

@@ -246,7 +246,8 @@ export const Event = {
"session.error",
z.object({
sessionID: SessionID.zod.optional(),
error: MessageV2.Assistant.shape.error,
// z.lazy defers access to break circular dep: session → message-v2 → provider → plugin → session
error: z.lazy(() => MessageV2.Assistant.shape.error),
}),
),
}