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
Socket appears not to be released if there is a connection error #1516
Comments
Hi @akc42, the behavior could be caused by the socket error is thrown before the script can properly call connection. close().
The error will be thrown even before the internal logic for socket error handling and socket close has not fully finished. Can you try add a connection.close() call before the throw statement, see if that closed the socket properly? This should be just a walk around. Also, I will discuses this within the team. I think the code could handle this part better, and the connection.close() call that added should not be necessary. |
@MichaelSun90 you have it about right, I just wrap things in promises, I decided to write a little test harness to test this. However I am finding that even the test harness only fails occasionally. Seemingly quicker without the
|
My work around
|
Software versions
Mar 14 2020 16:10:35
Copyright (C) 2019 Microsoft Corporation
Developer Edition (64-bit) on Linux (Ubuntu 18.04.4 LTS)
Additional Libraries Used and Versions
my own code
Table schema
N/A
Connection configuration
`
Problem description
Start my Node.js application that uses tedious.
I am turning the database off (its running as a docker container, so I just tell docker to stop the container).
Attempt a database connection through my software and let it fail.
Start the docker container again so that the database restarts;
Retry a database connection through my software;
I continue to get the following error
If I stop my application and then restart it. the error clears and I can use the database as normal
Expected behavior
Once the database has restarted connection requests should no longer fail, without restarting the application.
Actual behavior
As shown above, I continue to get socket failures at every attempt to call
new Connection(config)
Error message/stack trace
see above
Any other details that can be helpful
I can't prove it, but it looks as through the socket is not properly closed on the connection error. As a result Node.js is not cleaning it up.
The text was updated successfully, but these errors were encountered: