openpencil/apps/web/server/api/ai
Fini a42b145223 fix(ai): image-proxy timeout covers body read, not just headers
Codex flagged: the previous version cleared the AbortController
timeout in a finally{} block right after \`await fetch()\`, but
fetch() resolves as soon as the response headers arrive — the
body read happened later in the \`reader.read()\` loop with no
timeout protection. An upstream that drip-feeds bytes (or stops
mid-stream) would leave the dev server hanging on
reader.read() forever.

Single AbortController + timeout now covers the entire request
lifecycle (DNS + TLS + headers + body). The clearTimeout moves to
the outer finally{} so it fires regardless of return path
(success, 4xx, 5xx, abort) but never AHEAD of the body read.

Side benefit: AbortError thrown by the controller's timeout (or
by the size-cap controller.abort()) now lands in the catch clause
with a distinguishable error.name === 'AbortError'. Translate it
to a 504 Gateway Timeout when the timeout was the cause, so the
caller can distinguish a slow-upstream from a generic
fetch failure (502).
2026-05-05 12:22:55 +08:00
..
agent.ts V0.7.3 (#111) 2026-04-15 22:19:12 +08:00
chat.ts fix(ai): unwrap fetch error.cause for actionable network failures 2026-04-26 19:20:32 +08:00
connect-acp.ts V0.7.1 (#102) 2026-04-13 21:30:23 +08:00
connect-agent.ts V0.7.2-bugfix (#109) 2026-04-14 21:42:56 +08:00
generate.ts V0.7.2-bugfix (#109) 2026-04-14 21:42:56 +08:00
icon.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
image-generate.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
image-proxy.ts fix(ai): image-proxy timeout covers body read, not just headers 2026-05-05 12:22:55 +08:00
image-search.ts fix(ai): proxy openverse / wikimedia image fetches via local endpoint 2026-05-05 12:22:53 +08:00
image-service-test.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
install-agent.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
mcp-install.ts V0.7.3 (#111) 2026-04-15 22:19:12 +08:00
models.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
provider-models.ts fix(ai): unwrap fetch error.cause for actionable network failures 2026-04-26 19:20:32 +08:00
provider-url.ts fix(ai): unwrap fetch error.cause for actionable network failures 2026-04-26 19:20:32 +08:00
validate.ts V0.7.2-bugfix (#109) 2026-04-14 21:42:56 +08:00