[PR #22583] [CLOSED] fix: add 10 s AbortController timeout to getToolServerData fetch #42397

Closed
opened 2026-04-25 14:18:24 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22583
Author: @NIK-TIGER-BILL
Created: 3/11/2026
Status: Closed

Base: mainHead: fix/tool-server-fetch-timeout


📝 Commits (1)

  • 57874d5 fix: add 10s AbortController timeout to getToolServerData fetch

📊 Changes

1 file changed (+10 additions, -2 deletions)

View changed files

📝 src/lib/apis/index.ts (+10 -2)

📄 Description

Problem

When an enabled external tool server is unreachable, the frontend's fetch of openapi.json has no timeout, so the page hangs indefinitely with a spinner on every settings / chat load. No error is ever shown to the user (closes #22543).

Root cause

getToolServerData() in src/lib/apis/index.ts calls fetch(url) without a signal, so the browser connection never times out.

Fix

Add an AbortController with a configurable timeoutMs (default 10 s):

export const getToolServerData = async (token: string, url: string, timeoutMs = 10000) => {
  const controller = new AbortController();
  const timeoutId = setTimeout(() => controller.abort(), timeoutMs);

  const res = await fetch(url, { signal: controller.signal, ... })
    .then(async (res) => { clearTimeout(timeoutId); ... })
    .catch((err) => {
      clearTimeout(timeoutId);
      if (err?.name === 'AbortError') {
        error = `Request timed out after ${timeoutMs / 1000}s — server unreachable: ${url}`;
      } ...
    });
  • The timeout is cleared on both success and non-abort error paths to avoid memory leaks.
  • On abort, a clear human-readable error message is surfaced (instead of the raw AbortError).
  • The timeoutMs parameter defaults to 10 s but callers can override it.

Fixes #22543


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/22583 **Author:** [@NIK-TIGER-BILL](https://github.com/NIK-TIGER-BILL) **Created:** 3/11/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/tool-server-fetch-timeout` --- ### 📝 Commits (1) - [`57874d5`](https://github.com/open-webui/open-webui/commit/57874d5bea84a0e0e7b13c4460b7098fb4a7b796) fix: add 10s AbortController timeout to getToolServerData fetch ### 📊 Changes **1 file changed** (+10 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/apis/index.ts` (+10 -2) </details> ### 📄 Description ## Problem When an enabled external tool server is unreachable, the frontend's fetch of `openapi.json` has no timeout, so the page hangs indefinitely with a spinner on every settings / chat load. No error is ever shown to the user (closes #22543). ## Root cause `getToolServerData()` in `src/lib/apis/index.ts` calls `fetch(url)` without a `signal`, so the browser connection never times out. ## Fix Add an `AbortController` with a configurable `timeoutMs` (default **10 s**): ```ts export const getToolServerData = async (token: string, url: string, timeoutMs = 10000) => { const controller = new AbortController(); const timeoutId = setTimeout(() => controller.abort(), timeoutMs); const res = await fetch(url, { signal: controller.signal, ... }) .then(async (res) => { clearTimeout(timeoutId); ... }) .catch((err) => { clearTimeout(timeoutId); if (err?.name === 'AbortError') { error = `Request timed out after ${timeoutMs / 1000}s — server unreachable: ${url}`; } ... }); ``` - The timeout is cleared on both success and non-abort error paths to avoid memory leaks. - On abort, a clear human-readable error message is surfaced (instead of the raw `AbortError`). - The `timeoutMs` parameter defaults to 10 s but callers can override it. Fixes #22543 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-25 14:18:24 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#42397