Is it possible to kill an asynchronous function call in node.js or do I have to call the function and then another one to kill the whole process after a specific amount of time?
Probably not, But check following code, you can get some idea to achieve the stuff.
var logrunningFunction = function(){
setTimeout(function(){
console.log("Delayed");
cb();
}, 5000);
};
var cb = function(){
console.log("long running function completed");
};
logrunningFunction(cb);
setTimeout(function(){
cb = function(){
console.log("Overwrite long running handler");
};
},1000);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With