Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for timeout like in axios #35

Closed
germanviscuso opened this issue May 16, 2019 · 4 comments
Closed

Support for timeout like in axios #35

germanviscuso opened this issue May 16, 2019 · 4 comments

Comments

@germanviscuso
Copy link

See: axios/axios#1503
Being able to pass a timeout to the async call is convenient.

@mikeal
Copy link
Owner

mikeal commented May 17, 2019

Can’t you just wrap it in a generic promise timeout library?

@germanviscuso
Copy link
Author

germanviscuso commented May 21, 2019

This ibrary helps abstract the developer from thinking in promises terms. Look at the usage example, no (explicit) promises:

const bent = require('bent')

const getJSON = bent('json')
const getBuffer = bent('buffer')

let obj = await getJSON('http://site.com/json.api')
let buffer = await getBuffer('http//site.com/image.png')

hence IMHO it would be helpful to be able to do something like this (async/wait style, no promises, no extra lines of code except for the try/catch):

try {
  await getJSON('http://site.com/json.api', 5000); // 5 sec timeout
} catch(error) {
  // determine if error was from a timeout or not
}

@mikeal
Copy link
Owner

mikeal commented Nov 27, 2019

With browser support being quite good now and the bundle size being low, I’m not going to be adding features that increase the bundle size if they can easily be accomplished by pulling in other modules.

@mikeal mikeal closed this as completed Nov 27, 2019
@mpareja
Copy link

mpareja commented Feb 12, 2020

Cross-posting from #59:

Ancillary libraries for handling timeouts are insufficient without bent providing a mechanism to reclaim resources.

The request timeout implementation, for instance, aborts the request resulting in the TCP socket being torn down - that's important on a server. bent doesn't support setting a timeout nor gives us access to node's ClientRequest instance, so we won't have any way to tear down the TCP connection when using a timeout library.

Please consider re-opening this issue or warning others about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants