BetterTyped / hyper-fetch

⚡ Fetching and realtime data exchange framework.
https://hyperfetch.bettertyped.com/
Apache License 2.0
1.02k stars 27 forks source link

Settings for Increasing the request default timeout (default adapter) #44

Closed johngerome closed 1 year ago

johngerome commented 1 year ago

Is your feature request related to a problem? Please describe. Hi, I've noticed that a request get cancelled If it takes more than 5 seconds to response. Can't find the correct configuration for this one here.

Is there any way I can increase the default timeout ?

In the browser adapter (even on the server), I can see the default timeout but I'm not really sure If this is the reason. https://github.com/BetterTyped/hyper-fetch/blob/ef4e3acc93f39de0ae7b742ceb46c66e859f438d/packages/core/src/adapter/adapter.browser.ts#L26

Any help would be much appreciated. Thank you.

johngerome commented 1 year ago

Apparently I can override the timeout per request e.g. which solves my problem.

getUsers: client.createRequest()({
    endpoint: `/users`,
    options: {
        timeout: DateInterval.minute * 1,
   },
})

Not sure if It would be good to override the timeout in the Client as well ?

prc5 commented 1 year ago

@johngerome This is correct! We can set it globally on the Client with default options (setRequestDefaultOptions) or we can adjust it for particular Request with options property directly. I will add section to the docs Explaining this. 🙏👍

johngerome commented 1 year ago

@prc5 Perfect! Thank you so much.

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 5.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: