Skip to content

Improve API request error handling and add support for customizing requestTimeout - #1267

Merged
sserrata merged 2 commits into
mainfrom
improve-error-handling
Dec 19, 2025
Merged

sserrata merged 2 commits into
mainfrom
improve-error-handling

Conversation

@sserrata

Copy link
Copy Markdown
Member

Description

Implements better error handling for network and CORS-related errors and introduces requestTimeout option to themeConfig.api for globally customizing timeout.

Motivation and Context

In some cases, errors due to timeouts were getting masked in the UI resulting in confusion for end users.

How Has This Been Tested?

Deploy preview

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes if appropriate.
  • All new and existing tests passed.

- Add custom RequestError class with typed error categories (timeout, network, cors, unknown)
- Replace Promise.race timeout with AbortController for cleaner timeout handling
- Add descriptive error messages for different failure scenarios
- Add translation IDs for internationalization of error messages
- Update Request component to display context-specific error messages
…port

- Increase default request timeout from 5s to 30s
- Add requestTimeout option to themeConfig.api for site-wide configuration
- Support proxy in themeConfig.api as site-wide default (per-spec plugin option takes precedence)
- Update documentation in README.md, plugin README.md, and intro.mdx
@sserrata sserrata self-assigned this Dec 19, 2025
@sserrata sserrata added the enhancement New feature or request label Dec 19, 2025
@github-actions

Copy link
Copy Markdown

Size Change: +4.91 kB (+0.23%)

Total Size: 2.15 MB

Filename Size Change
demo/build/index.html 89.3 kB +4.91 kB (+5.82%) 🔍
ℹ️ View Unchanged
Filename Size
demo/.docusaurus/codeTranslations.json 2 B
demo/.docusaurus/docusaurus.config.mjs 14.6 kB
demo/.docusaurus/globalData.json 56.1 kB
demo/.docusaurus/i18n.json 267 B
demo/.docusaurus/registry.js 81.3 kB
demo/.docusaurus/routes.js 77 kB
demo/.docusaurus/routesChunkNames.json 31.8 kB
demo/.docusaurus/site-metadata.json 1.51 kB
demo/build/assets/css/styles.********.css 145 kB
demo/build/assets/js/main.********.js 714 kB
demo/build/assets/js/runtime~main.********.js 20 kB
demo/build/petstore/add-pet/index.html 27.8 kB
demo/build/petstore/create-user/index.html 22.5 kB
demo/build/petstore/create-users-with-array-input/index.html 22.6 kB
demo/build/petstore/create-users-with-list-input/index.html 22.6 kB
demo/build/petstore/delete-order/index.html 22.5 kB
demo/build/petstore/delete-pet/index.html 22.6 kB
demo/build/petstore/delete-user/index.html 22.8 kB
demo/build/petstore/find-pets-by-status/index.html 23.2 kB
demo/build/petstore/find-pets-by-tags/index.html 23.9 kB
demo/build/petstore/get-inventory/index.html 21.8 kB
demo/build/petstore/get-order-by-id/index.html 22.8 kB
demo/build/petstore/get-pet-by-id/index.html 23.3 kB
demo/build/petstore/get-user-by-name/index.html 22.9 kB
demo/build/petstore/login-user/index.html 23.4 kB
demo/build/petstore/logout-user/index.html 22.2 kB
demo/build/petstore/new-pet/index.html 22.7 kB
demo/build/petstore/pet/index.html 21 kB
demo/build/petstore/place-order/index.html 22 kB
demo/build/petstore/schemas/apiresponse/index.html 23.3 kB
demo/build/petstore/schemas/cat/index.html 37.2 kB
demo/build/petstore/schemas/category/index.html 24.3 kB
demo/build/petstore/schemas/dog/index.html 37.6 kB
demo/build/petstore/schemas/honeybee/index.html 37.7 kB
demo/build/petstore/schemas/id/index.html 21.4 kB
demo/build/petstore/schemas/order/index.html 25.5 kB
demo/build/petstore/schemas/pet/index.html 37.1 kB
demo/build/petstore/schemas/tag/index.html 22.7 kB
demo/build/petstore/schemas/user/index.html 44.8 kB
demo/build/petstore/store/index.html 20.2 kB
demo/build/petstore/subscribe-to-the-store-events/index.html 28.8 kB
demo/build/petstore/swagger-petstore-yaml/index.html 29 kB
demo/build/petstore/update-pet-with-form/index.html 22.7 kB
demo/build/petstore/update-pet/index.html 23.1 kB
demo/build/petstore/update-user/index.html 22.8 kB
demo/build/petstore/upload-file/index.html 22.6 kB
demo/build/petstore/user/index.html 20.7 kB

compressed-size-action

@github-actions

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 8512674):

https://docusaurus-openapi-36b86--pr1267-dpqrf91n.web.app

(expires Sun, 18 Jan 2026 17:01:51 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: bf293780ee827f578864d92193b8c2866acd459f

@sserrata
sserrata merged commit bac31b9 into main Dec 19, 2025
@sserrata
sserrata deleted the improve-error-handling branch December 19, 2025 17:33
@berkodeon

berkodeon commented May 7, 2026 •

Copy link
Copy Markdown

I think this PR fixed couple of issues (partially): (I don't understand why they are closed since they were active problems!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants