【问题标题】:Lambda function times out after finishingLambda 函数完成后超时
【发布时间】:2019-04-09 09:01:52
【问题描述】:

我有一个 lambda 函数正在完成且没有错误(我到达 console.log() 行),但仍然超时。我曾尝试使用lambda-local 进行调试,但找不到问题所在。我读了多个地方,我应该在我的处理函数中包含context.callbackWaitsForEmptyEventLoop = false,但这没有区别错误。是否还有其他我遗漏或未调用的内容阻止此函数超时?在打印consol.log() 函数、END RequestID 和 REPORT RequestID 后,将打印此错误2018-11-05T23:42:24.357Z 705cea03-e154-11e8-8089-87f7086f1090 Task timed out after 3.00 seconds

这是我的处理程序的功能:

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

【问题讨论】:

  • 我的印象是 lambda 应该如何表现。也许您正在寻找不同的 AWS 解决方案?
  • 当您说“超时”时,您指的是什么?您描述的哪些症状表明它已超时?
  • @jarmod 我更新了问题来回答你的问题。

标签: node.js amazon-web-services aws-lambda


【解决方案1】:

你错过了一个回调。

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

由于您禁用了callbackWaitsForEmptyEventLoop。它将等到您启动 callback 函数调用。

希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-15
    • 1970-01-01
    • 1970-01-01
    • 2020-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多