fix: opencode hanging when using client.app.log() during initialization (#11642)

This commit is contained in:
Desmond Sow
2026-02-02 03:14:34 +08:00
committed by GitHub
parent cc1d3732bc
commit eace76e525

View File

@@ -185,12 +185,15 @@ export namespace Server {
}, },
) )
.use(async (c, next) => { .use(async (c, next) => {
let directory = c.req.query("directory") || c.req.header("x-opencode-directory") || process.cwd() if (c.req.path === "/log") return next()
const raw = c.req.query("directory") || c.req.header("x-opencode-directory") || process.cwd()
const directory = (() => {
try { try {
directory = decodeURIComponent(directory) return decodeURIComponent(raw)
} catch { } catch {
// fallback to original value return raw
} }
})()
return Instance.provide({ return Instance.provide({
directory, directory,
init: InstanceBootstrap, init: InstanceBootstrap,