fix: resolve compiled binary crashes from circular dep and Bun CJS splitting bug
This commit is contained in:
parent
ce209e22a2
commit
2b3d027e3b
3 changed files with 8 additions and 3 deletions
|
|
@ -13,7 +13,8 @@ import { Installation } from "../../installation"
|
||||||
import { PushRelay } from "../../server/push-relay"
|
import { PushRelay } from "../../server/push-relay"
|
||||||
import { Log } from "../../util"
|
import { Log } from "../../util"
|
||||||
import { Global } from "../../global"
|
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" })
|
const log = Log.create({ service: "serve" })
|
||||||
|
|
||||||
|
|
@ -184,6 +185,7 @@ async function printPairQR(pair: PairPayload) {
|
||||||
linkLength: link.length,
|
linkLength: link.length,
|
||||||
qr: qrConfig,
|
qr: qrConfig,
|
||||||
})
|
})
|
||||||
|
const QRCode: typeof QRCodeType = await import("qrcode")
|
||||||
const code = await QRCode.toString(link, {
|
const code = await QRCode.toString(link, {
|
||||||
...qrConfig,
|
...qrConfig,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ import { errors } from "../../error"
|
||||||
import { lazy } from "@/util/lazy"
|
import { lazy } from "@/util/lazy"
|
||||||
import { Effect, Option } from "effect"
|
import { Effect, Option } from "effect"
|
||||||
import { PushRelay } from "../../push-relay"
|
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 { Agent } from "@/agent/agent"
|
||||||
import { jsonRequest, runRequest } from "./trace"
|
import { jsonRequest, runRequest } from "./trace"
|
||||||
|
|
||||||
|
|
@ -60,6 +61,7 @@ function pushPairLink(input: { relaySecret: string; hosts: string[] }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function pushPairQRCode(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)
|
return QRCode.toDataURL(pushPairLink(input), pushPairQROptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,8 @@ export const Event = {
|
||||||
"session.error",
|
"session.error",
|
||||||
z.object({
|
z.object({
|
||||||
sessionID: SessionID.zod.optional(),
|
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),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue