-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running function locally hangs (when using mysql connection pool) #470
Comments
I've just tested this with 0.1.0 and it still behaves the same way: Running the function locally (through |
same issue here |
For everybody still having this issue... I think it's arguable whether this is a bug or not. The reason So should Serverless exit the process when the function call completes or not? I don't know. But judging from @eahefnawy 's response to close this report, I assume the expected behavior is to keep running. |
I'm new to Serverless (JAWS), so I might overlook something obvious here. I've a very simple test function that uses the
mysql
node module, instantiates a connection pool, gets a connection and then releases it again:This function works perfectly fine when deployed to AWS, it exits within a few milliseconds and the world is bright and beautiful. However, running this function locally with
serverless function run
, it will print "Done.
" at the end, but never exit.I figured out that the reason probably is that I'm not releasing the mysql connection pool. If I change the last command in the above function to the following, then everything works:
It seems that Serverless is waiting for the mysql event loop to finish and wont exit unless that happens. However, to my understanding I should not close the connection pool so future calls of the same Lambda function will be able to reuse the pool and thus won't require a new DB connection but reuse an existing one.
So is the behavior of Serverless expected here to block or is this a bug? I was under the impression that calling
context.done()
would finish and return. So I would expect that Serverless exits when testing this locally.The text was updated successfully, but these errors were encountered: