openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

feat: add timeout support to RequestContext and isomorphic-fetch

Open dahaque opened this issue 2 months ago • 0 comments

This PR adds first-class timeout support to the typescript-fetch generator so users can prevent requests from hanging indefinitely.

Why?

The current typescript-fetch client doesn’t offer any way to cancel or fail a request after a specified time. When Kubernetes or any API becomes slow, consumers have no built-in way to enforce a timeout leading to stalled network calls.

This PR introduces a simple, lightweight solution.

What this PR does

  1. Adds a withTimeout() wrapper -Wraps fetch with an AbortController -Automatically aborts the request when timeout limit is reached -Forwards user-provided abort signals correctly

  2. Extends RequestContext -Adds a timeout?: number property -Ensures timeout travels through the request flow cleanly

  3. Integrates timeout into the generated IsomorphicFetchHttpLibrary -Replaces direct use of fetch -Uses withTimeout(fetch, request.getTimeout()) so all requests automatically inherit the timeout setting

dahaque avatar Dec 10 '25 05:12 dahaque