source_constants_timeouts.bs

' @fileoverview Centralized timeout constants for API requests and task coordination.
' All values in milliseconds.

namespace timeouts

  ' Default HTTP request timeout passed to roku-requests.
  ' Used by ApiTask and SideEffectTask for all API pool requests.
  const HTTP_MS = 10000

  ' API pool caller wait (fetchRes).
  ' 2s buffer above HTTP_MS so the HTTP layer times out first,
  ' preventing orphaned pool slots when the wait expires before the HTTP call.
  const API_WAIT_MS = 12000

  ' Whole-run budget for one apiPipeline run (source/api/apiPipeline.bs).
  ' ONE deadline across every request in the run, not a fresh one per request:
  ' a per-request wait lets N slow requests stack into N * API_WAIT_MS, so a
  ' dead server made a 10-library Home churn for ~48s. Must exceed API_WAIT_MS
  ' or a single slow-but-successful request gets cut short.
  '
  ' This is a budget, not a guarantee of coverage. A run services roughly
  '   PIPELINE_RUN_MS / per-request-latency * apiPool.SLOT_COUNT
  ' requests before it expires, and every entry past that is yielded undelivered.
  ' At the 11-library Home's measured ~132ms/request that is far more headroom
  ' than needed; at ~5s/request on a slow link it is about 12. So on a large,
  ' distant server the tail of a run legitimately fails, and callers must treat
  ' an undelivered entry as "no answer" rather than as data — see
  ' components/home/LoadLatestRowsTask.bs and source/home/latestRows.bs.
  const PIPELINE_RUN_MS = 20000

  ' Fallback-font scale measurement wait (main.bs calculateFontScaleFactor).
  ' A safety net for a task that never reports, not an expected duration — it measures two
  ' labels. Blocks the main thread during bootstrap, so it is not larger.
  const FONT_SCALE_MS = 10000

  ' Session connection check timeout.
  ' Intentionally higher to accommodate slow/remote servers
  ' and redirect chains during initial connection.
  const CONNECTION_CHECK_MS = 35000

end namespace