You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I'm frustrated with intermittent network issues causing failures in unary calls.
Describe the solution you'd like
Add automatic retry support with configurable timeouts to connect-es client middleware for unary calls.
Describe alternatives you've considered
Manual retry logic at the application level introduces complexity and duplication. Centralizing retries in the middleware ensures consistency and ease of maintenance.
The text was updated successfully, but these errors were encountered:
Yes, certain errors can be anticipated and retried, while others may not. The middleware should be configurable based on error codes. f.e network error or rate limit of api.
Including the middleware as part of the core package seems out of scope. The logic to when and how to retry is beyond the scope of an RPC library, it purely depends on the environment and the API being accessed. But implementing a unary retry is straightforward:
import{Code,ConnectError,typeInterceptor,}from"@connectrpc/connect";constretryInterceptor: Interceptor=(next)=>{returnasync(req)=>{if(req.stream){returnawaitnext(req);}for(leti=0;;i++){try{returnawaitnext(req);}catch(err){if(i==5){throwerr;}constcErr=ConnectError.from(err);if(cErr.code==Code.ResourceExhausted){// Wait for a bit and retryawaitnewPromise((resolve)=>setTimeout(resolve,1000));}else{throwerr;}}}};};
As you can see most of the code is just to decide and when and how to retry. Closing this issue for now, feel free to reopen if needed.
Is your feature request related to a problem? Please describe.
I'm frustrated with intermittent network issues causing failures in unary calls.
Describe the solution you'd like
Add automatic retry support with configurable timeouts to connect-es client middleware for unary calls.
Describe alternatives you've considered
Manual retry logic at the application level introduces complexity and duplication. Centralizing retries in the middleware ensures consistency and ease of maintenance.
The text was updated successfully, but these errors were encountered: