Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

2.6 KB
Raw Blame

Show Page API Request Timeout

Background

Show Runtime currently gives every proxied HTTP request the same 30-second transport timeout. That is appropriate for page assets, but it turns a healthy, slow synchronous Show Page API handler into the same 503 response used when the Runtime itself is unavailable.

PR #1634 separately changes the Show Runtime admission-outcome contract in the same core and UI proxy files. This change remains based on origin/master and adds a narrow per-call timeout contract so either merge order can preserve both owners without making one PR depend on the other.

Goal

  • Give Show Page API handlers a 90-second default deadline.
  • Expose the deadline as runtime.show_page_api_timeout_seconds through the existing V2Config and GET/POST /api/config contract.
  • Return HTTP 504 with show_runtime_request_timeout for an expired handler, while preserving HTTP 503 with show_runtime_unavailable for other Runtime failures.
  • Preserve the existing 30-second behavior for ordinary page assets, shared Runtime assets, prewarming, access control, and header filtering.

Solution

The UI proxy resolves the V2Config value when it forwards a page-authored /api request and passes it explicitly to ShowRuntimeManager.request. An omitted timeout preserves the manager's existing 30-second HTTPX phase timeout without adding a total deadline, so ordinary assets, prewarming, and Runtime protocol paths remain unchanged. Config writes affect subsequent page API requests without restarting Avibe.

The Runtime manager wraps the HTTP request in an overall cancellation deadline, so a response that keeps streaming small chunks cannot run indefinitely. It normalizes both deadline expiry and HTTPX read expiry into a dedicated exception. The response boundary maps that exception to 504 only for page-authored api and api/* paths. The broader __show/* Runtime protocol space, annotation, connection, and other Runtime failures stay on the unavailable path. This keeps the machine contract stable without coupling V2Config into the Runtime manager or adding an environment-only source of truth.

Validation

  • V2Config default, validation, persistence, projection, and partial-save tests
  • Runtime transport timeout tests for the 30-second default and per-call override
  • Private and public Show Page API proxy tests for the 90-second default, immediate config updates, distinct timeout errors, access behavior, and security-header filtering

Residual manual validation is one real handler that completes after 30 seconds and before 90 seconds through both private and public URLs.