I have this piece of code that runs perfectly fine locally.
But after I deployed it to AWS Lambda, it didn’t execute as expected, plus, it did not print any errors to CloudWatch for me to see what had happened.
I assume that it was because of the async/await
that caused it but it seems to be correct.
Did anyone witness it before?
JavaScript
x
23
23
1
module.exports.fetch = async event => {
2
const getParametersResponse = await ssm.getParameters({
3
Names: [
4
"TOKEN",
5
"ACCESS_KEY"
6
]
7
})
8
9
await axios
10
.get(url)
11
.then(async (res) => {
12
return downloadFile(res.data, project)
13
})
14
.then(async () => {
15
const readStream = await zipFile.openReadStream(entry)
16
return sendToDrive(readStream, project, gdriveKey)
17
})
18
.catch((error) => {
19
console.log("error")
20
})
21
};
22
23
CloudWatch details:
Advertisement
Answer
It looks like your function has a timeout set to a too-small value. By default, the timeout is set to 3 seconds, and if I’m not mistaken that’s what can be seen in the logs you’ve pasted. Increase the timeout and the function should be able to execute.