Async: Async debug timeout

Created on 19 Oct 2016  路  2Comments  路  Source: caolan/async

It would be very helpful for debugging and testing purposes if async had a timeout that could be set be set on all async operators.

Use case would be

async._debug({timeout: 2000})

async.waterfall([
 (next) => next(),
 (next) => 'bad function'
], (err, res) => {
   if(err){
     throw err;
   } 
})


// Debug timeout of 2000ms occurred  at {stack} 

Or something like that

enhancement question wont fix

Most helpful comment

We already offer a timeout wrapper.

You could do something like:

let debugWrap = process.env.DEBUG ? async.timeout : _.identity;
let waterfall = debugWrap(async.waterfall);

waterfall([
  (next) => {...}
  (next) => 'bad function'
], (err, res) => {
   if(err){
     throw err;
   } 
})

I'd be disinclined to build this in to the lib, though.

All 2 comments

We already offer a timeout wrapper.

You could do something like:

let debugWrap = process.env.DEBUG ? async.timeout : _.identity;
let waterfall = debugWrap(async.waterfall);

waterfall([
  (next) => {...}
  (next) => 'bad function'
], (err, res) => {
   if(err){
     throw err;
   } 
})

I'd be disinclined to build this in to the lib, though.

Yep, @aearly solution is definitely the way to go

Was this page helpful?
0 / 5 - 0 ratings