fix(AI): Bun.serve 空闲超时调到 60 秒,AI 流不再在 10 秒静默后被掐断
Bun.serve 默认 idleTimeout 是 10 秒:连接上 10 秒没有字节往来就直接断开,不报任何错。 AI 的两条 SSE 都会静默超过 10 秒 —— streamWhole(AI 提示)在 produce 期间每 15 秒 才发一次心跳,一次生成加过滤重生成常常超过 10 秒;streamChat 等首 token 也常过 10 秒。 学生看到的就是「AI 提示生成失败」。 对齐反代链上最短的一环(NPM proxy_read_timeout 60s)。实测:provider 挂住时原来 10 秒整连接被断、客户端收不到 error 事件;改后按 streamChat 自己的 45 秒空闲超时收尾。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b38ad8ccee
commit
04c0ccd304
1 file changed
+5
@@ -86,6 +86,11 @@ async function serveUpload(
|
||||
|
||||
const server = Bun.serve<SubmissionSocketData>({
|
||||
port: config.port,
|
||||
// Bun 默认 10 秒没有字节往来就掐连接,而且不报任何错。AI 的 SSE 两条路都会静默
|
||||
// 超过 10 秒:streamWhole 在 produce 期间每 15 秒才发一次心跳,streamChat 等首
|
||||
// token 也常过 10 秒 —— 学生看到的就是「AI 提示生成失败」。对齐反代链上最短的
|
||||
// 那一环(NPM 的 proxy_read_timeout 60s),两边的心跳 / 空闲超时都在它之内。
|
||||
idleTimeout: 60,
|
||||
async fetch(request, bunServer) {
|
||||
const url = new URL(request.url)
|
||||
if (url.pathname.startsWith(`${config.avatarUriPrefix}/`)) {
|
||||
|
||||
Reference in new issue
Block a user