'Lambda function not exiting
I am using the serverless framework to create a lambda function. I am running into an issue where the function won't exit when I invoke it locally. I am not sure how I can get it to exit. I have the below function though the function name is changed and the code is removed except the return which comes after a bunch of await
lines.
module.exports.myfunction = async (event, context) => {
context.callbackWaitsForEmptyEventLoop = false
const { initClientDbConnection } = require('./db')
// DB setup
global.clientConnection = initClientDbConnection()
const dbConnection = await global.clientConnection
const billingDB = dbConnection.useDb('mydb')
// Do some stuff here with async/await
return { success: true }
}
I'm hoping someone could tell me why it won't exit when I invoke it manually. I have another function which is similar in format and it exists though this one won't
Additional details are this is a script that runs fully then gets to the return line and it will just hang on the cli. I have not deployed to AWS yet because I need it to work both locally and on AWS. As for debugging steps, I've provided enough to be useful I think? I show the context
and the return line. The rest runs perfectly fine it is just the exit that fails. I can leave it to hang for a while before it times out. I am not sure what the issue is that is causing it to hang.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|