From ed5867620006e872fe24f441739452458efcfd6d Mon Sep 17 00:00:00 2001 From: Daniel Bergdahl Date: Mon, 18 Apr 2016 12:18:36 +0200 Subject: [PATCH] Clear timeout after execution --- lib/invoke.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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); };