问题
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