Skip to content

AI client fetch has no timeout #74

Description

@DeFiVC

What

The fetch call to the AI service in ai-client.ts has no signal (AbortController) or timeout configuration. If the AI service hangs, the request will block indefinitely (Node.js undici default timeout is very generous).

Why

While the caller (quizService.generateQuiz) catches errors and falls back to placeholder questions, a hung connection keeps a Node.js event loop reference and socket open. Under AI service degradation, this can exhaust sockets.

Scope

  • Add an AbortController with a reasonable timeout (e.g., 30 seconds) to the fetch call
  • Ensure the timeout is configurable

Acceptance Criteria

  • Fetch calls to the AI service time out after a reasonable duration
  • Hung connections are cleaned up
  • The timeout value is configurable via environment variable or constant

Technical Context

  • File: src/modules/quizzes/ai-client.ts, lines 28-38
  • Consider using the existing withTimeout utility from src/stellar/resilience.ts or a similar pattern

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions