I was using nodejs aws-sdk to invoke a long time running Lamda function. As we know AWS has increased lambda execution time to 900 seconds. But I can not get the lamda invoke response after lamda executing 300 seconds.
Here is the issue reproduce guid:
AWS Lambda code (Node.js 10.x) named error-handle
:
const { promisify } = require('util')
const sleep = promisify(setTimeout)
exports.handler = async (event,context) => {
await sleep(310000);
return 'Success'
};
Lambda invoke index.js:
const AWS = require('aws-sdk');
const main = async() =>{
const lambda = new AWS.Lambda({
region:'ap-southeast-2',
maxRetries: 0,
httpOptions: {
timeout: 600000,
}
});
let result;
try {
result = await lambda.invoke({
FunctionName: 'error-handle',
InvocationType: 'RequestResponse',
Payload: ""
}).promise();
}catch(error){
result = error;
}
console.log(result);
return result;
}
main()
After I run node index.js
and wait for 310
seconds lambda execution time. I can see the lambda has been existed successfully. But I can not get response in my index.js
. After 600
seconds I will get timeout error according to my timeout config.
It seems AWS lambda has not increasing the execution time from 300
to 900
seconds properly with the api endpoint.