184
rated 0 times
[
185]
[
1]
/ answers: 1 / hits: 18436
/ 13 Years ago, sun, december 4, 2011, 12:00:00
This is a typical situation in node.js:
asyncFunction(arguments, callback);
When asynFunction
completes, callback
gets called. A problem I see with this pattern is that, if asyncFunction
never completes (and asynFunction
doesn't have a built-in time-out system) then callback
will never be called. Worse, it seems that callback
has no way of determining that asynFunction
will never return.
I want to implement a timeout whereby if callback
has not been called by asyncFunction
within 1 second, then callback
automatically gets called with the assumption that asynFunction
has errored out. What is the standard way of doing this?
More From » node.js