Skip to content

feat(vision-proxy): add configurable request timeout - #203

Open
esnho wants to merge 1 commit into
Vizards:mainfrom
esnho:main
Open

feat(vision-proxy): add configurable request timeout#203
esnho wants to merge 1 commit into
Vizards:mainfrom
esnho:main

Conversation

@esnho

@esnho esnho commented Jul 20, 2026

Copy link
Copy Markdown

Summary

Adds an optional Request timeout (ms) field to the Vision Proxy
settings panel so users can increase the HTTP timeout for slow vision
API endpoints. Previously the timeout was hardcoded at 30 seconds.

Behavior

Input Result
Empty / not set Falls back to the existing default (30 000 ms)
Any positive number Used as the fetch timeout for vision requests
Zero, negative, or non-finite Treated as unset → falls back to default
No upper cap No arbitrary limit — users decide what works for their endpoint

Files changed

  • src/provider/vision/types.ts — add optional timeoutMs to
    VisionProxyConfig
  • src/provider/vision/sources/endpoint/config.ts — add
    normalizeTimeoutMs() (validates > 0, no cap)
  • src/provider/vision/protocols/client.ts — use
    config.timeoutMs ?? DEFAULT_TIMEOUT_MS
  • src/provider/vision/ui/html.ts — add <input type="number"> field
    with label + hint
  • src/provider/vision/ui/script.ts — wire parsePositiveNumber(),
    applyState, collectConfig for the new field
  • src/i18n.ts — add field.timeoutMs / hint.timeoutMs strings for
    both en and zh dictionaries

Screenshots

image

Translation review requested

The Chinese (zh) translations for the new strings were written with the
help of an AI assistant. A native speaker should review them:

// i18n.ts — zh dictionary
'vision.panel.field.timeoutMs': '请求超时 (毫秒)',
'vision.panel.hint.timeoutMs': '留空使用默认 30 秒。值必须大于 0。',

Corresponding English:

'vision.panel.field.timeoutMs': 'Request timeout (ms)',
'vision.panel.hint.timeoutMs': 'Leave empty for the default 30 seconds. Must be greater than 0.',

🙏 Please flag anything that sounds unnatural or could be improved.

Allow users to set a custom HTTP timeout (in milliseconds) for Vision
Proxy API requests via the settings panel.  The field accepts any value
> 0; empty / invalid / ≤ 0 values fall back to the existing default of
30 seconds.  No upper cap is enforced.

Changes:
- types.ts:           add optional `timeoutMs` to `VisionProxyConfig`
- endpoint/config.ts: add `normalizeTimeoutMs()` (reject ≤ 0, no cap)
- protocols/client.ts: use `config.timeoutMs ?? DEFAULT_TIMEOUT_MS`
- ui/html.ts:         add `<input type="number">` for timeout
- ui/script.ts:       wire `parsePositiveNumber()`, `applyState`, `collectConfig`
- i18n.ts:            add `field.timeoutMs` / `hint.timeoutMs` for en + zh

Vizards commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Thanks — a configurable timeout is useful here. Before merging, could you add an explicit maximum for timeoutMs?

I suggest exactly 2_147_483_647 ms (2147483647) and enforcing it both in the backend normalization and on the HTML input with max="2147483647".

Node's setTimeout() treats any delay larger than 2147483647 as 1 ms. As written, an oversized user value would therefore produce an almost immediate timeout, which is the opposite of the intended behavior. The proposed maximum is about 24.86 days, so it should not restrict any realistic vision request.

It would also be good to accept integers only (step="1" and/or backend integer normalization), since Node truncates non-integer delays.

Reference: https://nodejs.org/api/timers.html#settimeoutcallback-delay-args

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.

2 participants