Skip to content

Timer object leaks #4

@rexsuecia

Description

@rexsuecia

The setTimeout() "leaks" in some way. Atleast when I am running within a gulp mocha test suite. If you cancel the timeout it works better.
So from

    setTimeout(function(){
        timeoutReached = true;
        callback(new Error("Task timed out after " + (timeout / 1000).toFixed(2) + " seconds"));
    }, timeout); 

    context.setCallback(function (err, message) {
        if (!timeoutReached) {
            callback(err, message);
        }
    });

    // execute lambda function
    if (lambdaFunc[handler]) {
        lambdaFunc[handler](eventObj, context);
    } else {
        callback(new Error('Could not find Lambda handler'));
    }

To:

var timer = setTimeout(function(){
        timeoutReached = true;
        callback(new Error("Task timed out after " + (timeout / 1000).toFixed(2) + " seconds"));
    }, timeout); 

    context.setCallback(function (err, message) {
        if (!timeoutReached) {
            callback(err, message);
        }
    });

    // execute lambda function
    if (lambdaFunc[handler]) {
        lambdaFunc[handler](eventObj, context);
        clearTimeout(timer);
    } else {
        callback(new Error('Could not find Lambda handler'));
    }
    clearTimeout(timer);

Could you possible do that change? Maybe if I make a pull request?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions