Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

HTTP requests in fluent-ai could hang indefinitely without a timeout mechanism, causing jobs to stall on slow or unresponsive endpoints.

Changes

Core HTTP layer (src/job/http.ts)

  • Added optional timeout parameter to createHTTPJob and downloadImages
  • Implemented timeout using AbortController API
  • Enhanced error messages to distinguish timeout from other failures

Schema (src/job/schema.ts)

  • Extended optionsSchema with optional timeout: number field (milliseconds)

Provider runners (src/job/*.ts)

  • Updated OpenAI, OpenRouter, Voyage, and Fal runners to pass timeout option from job options to HTTP layer

Tests (test/timeout.test.ts)

  • Added unit tests for timeout behavior, error handling, and backward compatibility

Usage

import { openai, user } from "fluent-ai";

// Timeout applies to the entire request
const job = openai({ timeout: 5000 })
  .chat("gpt-4o-mini")
  .messages([user("Hi")]);

await job.run(); // Throws "HTTP request timed out after 5000ms" on timeout

The timeout is optional and backward compatible—existing code continues to work without modification.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • httpbin.org
    • Triggering command: bun test test/timeout.test.ts (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>fetch with timeout error</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits November 18, 2025 04:18
Co-authored-by: wangzuo <1039026+wangzuo@users.noreply.github.com>
Co-authored-by: wangzuo <1039026+wangzuo@users.noreply.github.com>
Co-authored-by: wangzuo <1039026+wangzuo@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix fetch with timeout error Add timeout support for HTTP fetch requests Nov 18, 2025
Copilot AI requested a review from wangzuo November 18, 2025 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fetch with timeout error

2 participants