Blake Morgan
Blake Morgan

Reputation: 775

Lambda function times out after finishing

I have a lambda function that is completing without errors (I get to the console.log() line), but still times out. I have tried debugging with lambda-local, but cannot find where the hold up is. I read multiple places that I should include context.callbackWaitsForEmptyEventLoop = false in my handler function, but that makes no difference error. Is there something else I'm missing or not calling that is preventing this function from not timing out? After the consol.log() function gets printed, END RequestID, and REPORT RequestID, this error gets printed 2018-11-05T23:42:24.357Z 705cea03-e154-11e8-8089-87f7086f1090 Task timed out after 3.00 seconds

Here is my handler's function:

exports.handler = function(event, context, callback) {
    context.callbackWaitsForEmptyEventLoop = false
    let alexa = Alexa.handler(event, context);
    alexa.APP_ID = APP_ID;
    // To enable string internationalization (i18n) features, set a 
resources object.
    alexa.resources = languageStrings;
    alexa.registerHandlers(handlers);
    alexa.execute();
    console.log("You made it.")
};

Upvotes: 0

Views: 624

Answers (1)

Kannaiyan
Kannaiyan

Reputation: 13055

You are missing a callback.

exports.handler = function(event, context, callback) {
    context.callbackWaitsForEmptyEventLoop = false
    let alexa = Alexa.handler(event, context);
    alexa.APP_ID = APP_ID;
    // To enable string internationalization (i18n) features, set a 
resources object.
    alexa.resources = languageStrings;
    alexa.registerHandlers(handlers);
    alexa.execute();
    console.log("You made it.")
    callback(null,"Complete");
};

Since you have disabled callbackWaitsForEmptyEventLoop. It is going to wait until you initiate the callback function call.

Hope it helps.

Upvotes: 1

Related Questions