AWS Lambda stops working if it breaks once

耗尽温柔 提交于 2019-12-11 04:55:08

问题


I have a lambda with 5s timeout. Here is a simple lambda that I upload:

exports.handle = function(event, context, callback) {
    if (Math.random() < 0.5) {
        callback(null, "done");
    } else {
        setTimeout(() => callback(null, "delayed"), 6000);
    }
};

As you can see, 50% of the times it should just return 'done' but the other 50% of the time, there should be a delay that is higher than the timeout and I expect to get a timeout error.

Problem is, once I get the timeout error, I will ALWAYS get a timeout error. The lambda stops working.

How come? I even tried context.callbackWaitsForEmptyEventLoop = false without any success

来源:https://stackoverflow.com/questions/43928029/aws-lambda-stops-working-if-it-breaks-once

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