I am running an AWS Lambda function for image/video processing with Node 4.3 as a runtime. I am invoking my function from my webapp code with the node aws-sdk.
The issue is that when the function takes a long time to execute (e.g. 250 seconds), the invocation callback is never received, although I can clearly see in the aws cloudwatch logs that the function executed properly. On top of that the function is re-run again at least twice (this is probably related to the maxRetries parameter from the invocation: since it doesn't get a response back it retries).
What confuses me is that it works for quicker functions and my lambda function never times out. Anyone having such an issue ? Can it be related to the new 4.3 runtime? Note that I omit the context.succeed()
or context.fail()
as it is not required anymore, but I tried with it and it doesn't change a thing.
Lambda code
...
var handler = function (event, context, callback) {
// video/image processing code
//
// callback function
..., function(err, result) {
if (err) {
console.log("Error", err, err.stack);
callback(err);
} else {
console.log("Done");
callback(null, result);
}
}
};
Lambda Invocation
var lambda = new AWS.Lambda;
var myEventObject = {...};
var payload = JSON.stringify('myEventObject');
var params = {
FunctionName: 'myLambdaFunction'
InvocationType: 'RequestResponse',
LogType: 'None',
Payload: payload
};
lambda.invoke(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
Lambda CloudWatch Log
REPORT RequestId: xxx Duration: 206757.82 ms Billed Duration: 206800 ms Memory Size: 1536 MB Max Memory Used: 354 MB