Skip to content
Source
Sign inSign up
TanStack/schemas

Retry the OpenAI models listing on a transient 504 #687

Mergedtombeckenhammerged 1 commit intomain from100004-openai-one-upstream-504-on-get-v1-models-fails-the-whole-modmerged by tombeckenham View on GitHub

tombeckenhamcommented

listModels in src/server/providers/openai.ts read GET /v1/models with plain fetchJson, so one upstream 504 failed the whole OpenAI models poll (5 of ~24 polls on 2026-11-17).

It now reads the listing through fetchWithRetry, as Replicate and FAL do: retryable statuses, network failures and timeouts are retried with backoff (default 5 attempts), the Authorization header is built per attempt, and it still throws with the URL after the last attempt.

Tests in openai.test.ts: a 504 then a 200 yields the models; a 504 on every attempt throws fetch failed after 5 attempts: <url> → 504 Gateway Timeout.

No changeset: nothing under packages/* changed.

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability when retrieving available models from OpenAI: temporary gateway timeouts are retried before the request fails.
    • When repeated timeouts prevent model retrieval, the resulting error now includes the models endpoint and the final response status.
    1. tombeckenham linked this to fix #100004

    2. Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The OpenAI provider now fetches the models listing with fetchWithRetry, supplies bearer authorization, and parses the response as OpenAiModelList. Tests cover a successful retry after a 504 response and an error after five consecutive 504 responses.

      Changes: OpenAI model listing

      Layer / File(s)Summary
      Retry model-list requests
      src/server/providers/openai.ts, src/server/providers/openai.test.ts
      listModels uses fetchWithRetry with the bearer authorization header and parses the listing response. Tests verify that a 504 is retried with authorization on both attempts, and that five consecutive 504 responses produce an error containing the models URL and final status.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Merge Risk: Minimal · up to d40a3

      This change makes the OpenAI models listing retry after transient gateway timeouts. No actionable merge-blocking risk was found, and the new tests cover both the successful retry and the repeated-failure case.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Description CheckPassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title checkPassedThe title states the main change: the OpenAI models listing now retries on a transient 504. The raw summary confirms listModels switched from fetchJson to fetchWithRetry, and the new tests cover a 504…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Title check

      Explanation

      The title states the main change: the OpenAI models listing now retries on a transient 504. The raw summary confirms listModels switched from fetchJson to fetchWithRetry, and the new tests cover a 504 followed by success and repeated 504 failures. The title is specific and matches the changeset, so it passes.

      Finishing Touches

      Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      Share

      Recent review info

      Run configuration

      • Source mode: Auto
      • Repository: Unavailable
      • Branch: Unavailable
      • File: No configuration file from this repository applied
      • Commit: Unavailable
      • Layers: defaults
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: c967a0a2-801f-40ec-aa54-5a92d3734c86
      Commits

      Reviewing files that changed from the base of the PR and between 921aa0f1a88f77c24d9b4607e87d7868b701a8c0 and d40a33720d9d9bf5c6b1e75872ee756fc767e0ad.

      Files selected for processing: 2

      • src/server/providers/openai.test.ts
      • src/server/providers/openai.ts

      Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

    3. ⚠️ No Changeset found

      Latest commit: d40a33720d9d9bf5c6b1e75872ee756fc767e0ad

      Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

      This PR includes no changesets

      When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

      Click here to learn what changesets are, and how to add one.

      Click here if you're a maintainer who wants to add a changeset to this PR

    4. tombeckenham merged thisc601bbf

    5. tombeckenham merged thisc601bbf

    6. tombeckenham closed this

Sign in to join this conversation.