timeout event, and timeout option implemented. added docs & example #130

merged 2 commits into from Dec 11, 2013

5 participants


I was serially testing GET's on a million websites, and gradually came across my test app stalling with the same pattern.

It turned out that restler has/had no option for timeout. This is a show-stopper for large/production scenarios.

eg: The following code, stalls forever, without throwing an error or

  rest.get('http://tianji.com').on('complete', function(){ 
    console.log('never entered here');

infact it did not emit any known events either. namely error or abort.

 rest.get('http://tianji.com').on('error' function(ms){
   sys.puts('neither found an error');
  }).on('abort' function(ms){
   sys.puts('nor an abort');
   sys.puts('never reached here either');

I also saw previous mentions requesting timeout feature for restler.
eg: #3 one of the oldest open bugs/issues.

So i went ahead, forked and fixed this.

My commit includes :

  • added the 'timeout' event
  • added the {timeout:Ms} option
  • added documentation for timeout
  • added an example for timeout

Here's an example.

 rest.get('http://tianji.com',{timeout: 10000}).on('timeout' function(ms){
   sys.puts('did not return within '+ms+' ms');
   sys.puts('life goes on');

Will love to see this reviewed for a possible merge.

~Bosky @bhaskerkode






I'm happy to merge this with some tests. Any chance you could knock some up?

@easternbloc easternbloc merged commit 0ca56f7 into danwrong:master Dec 11, 2013
@easternbloc easternbloc referenced this pull request Dec 11, 2013

Feature/timeout tests #144

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment