Add explicit timeouts and bounded retries for external dependencies #16

Open
opened 2026-03-15 01:25:56 +00:00 by Francy51 · 0 comments
Owner

Several external I/O paths have no explicit deadlines, and some intentionally disable retries entirely.

Why this is a problem:

  • Slow upstreams can stall requests or background work unpredictably.
  • Transient failures become immediate hard failures even when a bounded retry would succeed.
  • Runtime behavior under dependency degradation is not predictable.

Observed in:

  • lib/server/sec.ts
    • filing text and JSON fetches have no timeout/abort handling
  • lib/server/prices.ts
    • Yahoo requests have no timeout/abort handling
  • lib/server/financials/kpi-notes.ts
    • note HTML fetches have no timeout/abort handling
  • lib/server/ai.ts
    • generateText and embedMany are invoked with maxRetries: 0

Suggested direction:

  • Introduce a shared server-side fetch helper with:
    • explicit timeout via AbortController
    • bounded retries for transient failures
    • consistent error classification
  • Apply the helper to SEC, Yahoo, and other external HTTP integrations.
  • Revisit AI retry policy so idempotent operations can tolerate transient provider failures.

Acceptance criteria:

  • External HTTP calls have explicit deadlines.
  • Transient failures use bounded retry policy where safe.
  • Timeouts and retry exhaustion are surfaced as clear, typed failures.
  • Tests cover timeout and retry behavior for at least one representative integration.
Several external I/O paths have no explicit deadlines, and some intentionally disable retries entirely. Why this is a problem: - Slow upstreams can stall requests or background work unpredictably. - Transient failures become immediate hard failures even when a bounded retry would succeed. - Runtime behavior under dependency degradation is not predictable. Observed in: - `lib/server/sec.ts` - filing text and JSON fetches have no timeout/abort handling - `lib/server/prices.ts` - Yahoo requests have no timeout/abort handling - `lib/server/financials/kpi-notes.ts` - note HTML fetches have no timeout/abort handling - `lib/server/ai.ts` - `generateText` and `embedMany` are invoked with `maxRetries: 0` Suggested direction: - Introduce a shared server-side fetch helper with: - explicit timeout via `AbortController` - bounded retries for transient failures - consistent error classification - Apply the helper to SEC, Yahoo, and other external HTTP integrations. - Revisit AI retry policy so idempotent operations can tolerate transient provider failures. Acceptance criteria: - External HTTP calls have explicit deadlines. - Transient failures use bounded retry policy where safe. - Timeouts and retry exhaustion are surfaced as clear, typed failures. - Tests cover timeout and retry behavior for at least one representative integration.
Francy51 added the P1 label 2026-03-15 01:25:56 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Francy51/Neon-Desk#16