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()
try { const raw = c.req.query("directory") || c.req.header("x-opencode-directory") || process.cwd()
directory = decodeURIComponent(directory) const directory = (() => {
} catch { try {
// fallback to original value return decodeURIComponent(raw)
} } catch {
return raw
}
})()
return Instance.provide({ return Instance.provide({
directory, directory,
init: InstanceBootstrap, init: InstanceBootstrap,