node-sdk icon indicating copy to clipboard operation
node-sdk copied to clipboard

Set timeouts to underlying requests

Open corlobepy opened this issue 7 years ago • 0 comments

The current requests rely on the timeouts defined in the browser or in the OS. When executing requests, I'd like to be able to set custom timeouts to the requests made by superagent:

https://visionmedia.github.io/superagent/#timeouts

request
  .get('/big-file?network=slow')
  .timeout({
    response: 5000,  // Wait 5 seconds for the server to start sending,
    deadline: 60000, // but allow 1 minute for the file to finish loading.
  })
  .then(res => {
      /* responded in time */
    }, err => {
      if (err.timeout) { /* timed out! */ } else { /* other error */ }
  });

This could be passed as options to the hyperwallet constructor or functions. Alternatively we could inject our own instance of superagent which would also give the ability to use custom plugins for superagent

corlobepy avatar Jul 13 '18 19:07 corlobepy