DB connections hangs after successful execution in Lambda locally
I'm testing my lambda functions locally with
sls invoke local -f hello
.
after returning a success response, my execution doesnt end
attached a video that shows the behaviour
if i remove the db query then it works fine14 Replies
I guess fot his case you need to close connection after it's finished. Or not use Pool and use a single connection in a driver you are using with Drizzle
We will also add this connection inside drizzle object, so you can disconnect right from
db
objectCould this cause issues in production with lambdas?
And how can i close the connection currently?
I use postgres-js as my driver and create my queryClient the following way
was looking how to close a connection as well
with prostgres-js, you close the connection with
.end()
:
what about with neon?
You could also define a timeout to auto close it:
I don't know neon but I found a
client.release();
where client would be :
If you could confirm or not 😄yeah but i guess this is not a good practice for lambda functions, since i don't want the connection to close as long as my lambda is warm
Without using drizzle at all, do you have the same issue?
because we can see that your function returns a result, so it ends well.
I don't know AWS lambda 🫣
well i'm switching from python to TS and i was using SQLAlchemy, there i didn't have this issue when using
sls invoke
At first it looked good to me and I would imagine that this is sls that doesn’t exit.
i agree it looks weird.
what happens if you comment all the code related to drizzle? (including imports)
ah sorry I read too fast...
yeah if i dont have the drizzle stuff then its fine
did this for now, i guess it works (also weird that i can't do 0 for idle_timeout)
is it this sls?
https://github.com/serverless/serverless/issues/6679
GitHub
Invoke local keeps hanging after response · Issue #6679 · serverles...
This is a Bug Report Description What went wrong? After invoking a function locally, the console does not exit, it hangs forever until I CTRL+C. What did you expect should have happened? Should exi...
yes
seems like a really old issue with no real solutions
any updates on when this feature will be added?