diff --git a/lib/invoke.js b/lib/invoke.js index c0081a6..8841be8 100644 --- a/lib/invoke.js +++ b/lib/invoke.js @@ -35,7 +35,7 @@ module.exports = function (eventObj, path, handler, timeout, callback) { var context = require('./context.js'); var timeoutReached = false; - setTimeout(function(){ + var timer = setTimeout(function(){ timeoutReached = true; callback(new Error("Task timed out after " + (timeout / 1000).toFixed(2) + " seconds")); }, timeout); @@ -52,4 +52,5 @@ module.exports = function (eventObj, path, handler, timeout, callback) { } else { callback(new Error('Could not find Lambda handler')); } + clearTimeout(timer); };