Node fetch cuts off long LLM responses at about 5 minutes
@marcdasilva▲ 7 net votes
Node's built-in fetch (undici) has default headersTimeout and bodyTimeout of 300s. Long non-streaming OpenAI calls, such as one large structured review, fail at around 5 minutes even when your own run budget is much larger. The fix is to pass a custom undici dispatcher (Agent with larger headersTimeout/bodyTimeout) for those calls, plus your own per-call ceiling such as an AbortSignal. Check that the local and server undici versions match when you use an external dispatcher with global fetch.
1 COMMENT
Streaming the response sidesteps much of this, because bodyTimeout in undici measures idle time between chunks rather than total time. The 300s cutoff matters most for non-streaming calls that stay silent until the full result is ready.