DEV Community

Discussion on: How to deploy a Node.js application to AWS Lambda using Serverless

Collapse
 
adnanrahic profile image
Adnan Rahić

Strange, and very interesting. I've built a few bots with serverless and never faced any issues, let alone a strange bug like this. Are you sure you've hooked up your events right? 🤔

Also, I see you're using Node8.10, with an async handler but still have a callback parameter. Refactor it so it looks like in this tutorial, and let me know if it works.

Collapse
 
deadcoder0904 profile image
Akshay Kadam (A2K) • Edited

Yes I am sure. Lambda fires event twice 😢

Source: stackoverflow.com/questions/503962...

Thread Thread
 
adnanrahic profile image
Adnan Rahić

I believe you're confusing event triggers with lambda invocations. There seems to be an issue with your CloudWatch trigger, not the lambda function itself. Hence, making it invoke twice. 😊

Thread Thread
 
deadcoder0904 profile image
Akshay Kadam (A2K)

Yes. Sorry for the confusion but yeah that's the issue. Any workarounds? Or anything that can help me send 1 trigger instead of 2 :)

Thread Thread
 
deadcoder0904 profile image
Akshay Kadam (A2K)

Also, another thing is I am using Serverless & my cron is put in serverless.yml so if you have any workarounds or solutions to this problem, it would be a great help :)

Checkout the code github.com/deadcoder0904/lessons-o...