Lambda function times out after finishing

痞子三分冷 提交于 2019-12-11 15:52:30

问题


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.")
};

回答1:


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.



来源:https://stackoverflow.com/questions/53163942/lambda-function-times-out-after-finishing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!