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

timeouts #17

Closed
tj opened this issue Aug 30, 2011 · 7 comments
Closed

timeouts #17

tj opened this issue Aug 30, 2011 · 7 comments

Comments

@tj
Copy link
Contributor

tj commented Aug 30, 2011

No description provided.

@runeh
Copy link

runeh commented Nov 20, 2011

I might use superagent for a mobile project, so I need interrupts to deal with shoddy mobile networks.

Experimented a bit over the weekend. I have some working code in my fork that works like this:

request('GET', '/slow')
    .interruptAfter("1.5s")
    .end(function(res){
        if (req.interrupted) { do stuff  and return }
        else { whatever }
    })

There's also a interruptEvery. The time argument can be a number of millis or a string of the form "300ms" or "1.5s".

Any opinons. Not entirely sure about the API. I'd be happy to fix up my branch and submit pull request if we could come up with a reasonable API.

@tj
Copy link
Contributor Author

tj commented Nov 20, 2011

I would definitely prefer .timeout(ms) personally

@runeh
Copy link

runeh commented Nov 20, 2011

As an alternative to .interruptAfter presumably? I kinda hate the term "timeout" as it's so generic, but in this context it makes sense I suppose. Would align with the naming of window.setTimeout.

How about interruptEvery is it needed? Could rename to .interval(ms), which soulds a bit weird, but would work.

@tj tj closed this as completed in ecdf0b9 Aug 28, 2012
@OlgaKozlova
Copy link

And what is default timeout for requesr? Can't find this info!

@jazoom
Copy link

jazoom commented Apr 9, 2016

I also can't find it. I want to create a longer timeout for a particular request.

@kornelski
Copy link
Contributor

By default there is no timeout (superagent will wait for the response forever). You set timeout with .timeout method, e.g. to wait up to 5 seconds: request.post('/foo').timeout(5000).end();

@jazoom
Copy link

jazoom commented Apr 11, 2016

Okay, thanks. That's good to know.

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

5 participants