Giter VIP home page Giter VIP logo

Comments (4)

dpopp07 avatar dpopp07 commented on July 17, 2024

Hi @kvv002

We do support a general timeout parameter in the constructor of the SDK, which should be sufficient for your use case, as the timeout should be applied to each retried request. Is there a reason that would not be sufficient?

from node-sdk-core.

kvv002 avatar kvv002 commented on July 17, 2024

Hi @dpopp07 , we have the below requirements:

  1. maxRetry
  2. retryDelay
  3. status codes to retry, including E-errors
  4. timeout for each retry
  5. total timeout including all the retries

With the SDK we were able to solve maxRetry and retryDelay, but for the 3rd point we need to have a configurable retries for E-errors for eg: 5 retries for these errors : [429, 502, 503, 504, 'ECONNRESET', 'ETIMEDOUT', 'EHOSTUNREACH', 'EAI_AGAIN', 'ECONNREFUSED', 'EAI_AGAIN', 'EPIPE']
We weren't able to solve the 3rd point with SDK alone, hence we switched to retry-axios library, using the below config with retry-axios we were able to solve point 1,2,3

const maxRetry = 5
const { IamAuthenticator } = Authenticator
const authenticator = new IamAuthenticator({
    apikey: CLOUDANT_APIKEY,
    timeout: 5000 //does not consider axios (5) retries for E-errors
  })

const service = new CloudantV1({
authenticator: authenticator
})
service.setServiceUrl(CLOUDANT_URL);

service.requestWrapperInstance.axiosInstance.defaults.raxConfig = {
  // ... retry-axios config options
  retry: maxRetry, 
  backoffType: 'static',
  retryDelay: 5000, 
  timeout: 5000, //does not time out
  statusCodesToRetry: [[100, 199], [400, 429], [500, 599]],
  noResponseRetries: maxRetry,
  onRetryAttempt: err => {
    const cfg = rax.getConfig(err);
    console.log('---err--2--', err.code, err.status)
    console.log(`Retry attempt #${cfg.currentRetryAttempt}`);
    const TIME_ELAPSED = (new Date() - start) / 1000
    console.log('--time----', TIME_ELAPSED)
  },
  instance: service.requestWrapperInstance.axiosInstance,
};
rax.attach(service.requestWrapperInstance.axiosInstance);

Now when we include the timeout in retry-axios it does not consider that, and if we include noResponseRetries in the SDK for E-errors it does not consider the same.

We need a workaround which can support all the above 6 points

from node-sdk-core.

dpopp07 avatar dpopp07 commented on July 17, 2024

@kvv002 Since we are using retry-axios to handle retries within the core, we are limited by what they support in their package.

For something like total timeout including all the retries, I don't believe that package supports that. You would need to request that feature be added to that library for there to be support here.

For configuring a per-request timeout, you need to provide a general timeout to the service client constructor:

const service = new CloudantV1({
  authenticator: authenticator,
  timeout: 5000,
})

from node-sdk-core.

padamstx avatar padamstx commented on July 17, 2024

I think this issue has been addressed, so closing it out.

from node-sdk-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.