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