Can’t push data to Firebase from within an Alexa Skill hosted on AWS Lambda


I have a database in Firebase to which I’m trying to write some data from within my Alexa Skill. The Node.js code for that skill sits inside an AWS Lambda function and when that code is run I want to push some data to Firebase.

I’ve tested the code that connects to and pushes to Firebase outside of Lambda and it works exactly as expected. Below is that code:

This same code doesn’t push anything to the database instance when executed from within the Lambda function. I read online that Lambda timeout limit could be a reason for this, so I increased the timeout limit to a minute, and it still doesn’t run as expected. I’ve also tried using the Firebase REST API instead of their Node.js SDK and that didn’t work either. What is the correct way to push data to Firebase from within AWS Lambda?


I think I know why this happens, I had a similar issue and this is what I’ve done.

If you want to write some date into your database you need to make sure that you don’t call this.emit(*****) until you are done. As soon as you return the response to the user the Thread gets closed and your information doesn’t get saved.

The easiest way to solve this problem is to return the response to the user once you get confirmation that the information has been saved.

In case of Firebase something like this:


I couldn’t get anything saved until I started doing it like this.

Hope it helps.

Leave a Reply