Skip to content

超时字段支持 0 = 不设限 - #99

Merged
YoungSx merged 1 commit into
mainfrom
check-timeout-zero-never-timeout
Sep 6, 2026
Merged

超时字段支持 0 = 不设限#99
YoungSx merged 1 commit into
mainfrom
check-timeout-zero-never-timeout

Conversation

@YoungSx

@YoungSx YoungSx commented Sep 6, 2026

Copy link
Copy Markdown
Owner

背景

LLM 长流式调用在既有上限(尤其 totalTimeoutMs 300s)下仍会中断。需要「永不超时」。

关键事实

setTimeout(fn, 0)下一个 tick 立即开火,不是永不。所以这不是把 UI 的 min=1 改成 min=0 就完事——0 必须三层一起认账:

  1. schemaconfig.ts):五个超时字段 positive()min(0),注释写明 0=禁用;跨字段校验(timeoutMs > totalTimeoutMs)在任一为 0 时跳过——关掉的时限不可能被超过。
  2. runtime:四处 timer 消费点在 0 时不武装——
    • forward.tsremaining() 返回 Infinity(否则负数预算会在第一次尝试前就跳出 walk);head deadline 不设 timer(runtime 会把超大 setTimeout 延迟钳到 ~1ms,「永不」变「立即」)。
    • stream-watch.ts:首字节/空闲看门狗 0 时不 arm。
    • response-cache.tsjoinFlight 0 时直接 await flight.done
    • auth.tsAbortSignal.timeout(0) 会立即 abort,改为不传 signal。
  3. UINUMERIC_BOUNDS):五个超时字段 min: 1min: 0,帮助文案补「填 0 表示不设限」。面板 worker 复用 jouska 的 configSchema,无第二份 schema。

测试

  • config.test.ts:0 被接受、timeoutMs: 60_000 + totalTimeoutMs: 0 不再误报矛盾。
  • stream-watch.test.ts:双 0 下静默 150ms 的流活到最后 complete。
  • streaming.test.ts(集成):全 0 配置下带间隙的 SSE 完整透传、无 abort——这是「0 不是立即超时」的直接证明。
  • npm run check(CI 同款)全绿:lint 0 error,4 工作区 1224 tests passed。

🤖 Generated with Claude Code

0 在 setTimeout/AbortSignal.timeout 里是立即开火不是永不,所以 schema 放行
之外,runtime 的头超时、总预算、两段流式看门狗、joinFlight、forwardAuth
deadline 都要先把 0 拦下来。UI 边界与帮助文案同步注明语义。

Co-Authored-By: Claude <noreply@anthropic.com>
@YoungSx
YoungSx merged commit b311db1 into main Sep 6, 2026
1 check passed
@YoungSx
YoungSx deleted the check-timeout-zero-never-timeout branch September 6, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant