question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Open handle after unsuccessful call to `.connect` keeps process running

See original GitHub issue

If a call to .connect fails, the module prevents the process from exiting gracefully and a call to process.exit is needed, which should not be the case.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jheckingcommented, Apr 20, 2021

Definitely a difference. When calling .close on the same reference of the client I call the (then failing) .connect on, the process is kept alive. When I extract the client out of the error and call .close on that, the process does exit as expected.

Hmm, that’s interesting. I cannot reproduce that behavior using this simplified test case:

const as = require('aerospike')
const client = new as.Client({ hosts: '127.0.0.1:8888'})
client.connect().catch((error) => {
  console.error(error.message)
  client.close()
})

After closing the client instance the process terminates immediately in my case.

PRs to improve the documentation are always welcome! The AerospikeError docs already mention about the referenced client instance and the fact that it can be used to close the connection in the case of errors: https://www.aerospike.com/apidocs/nodejs/AerospikeError.html#client. (Generated from lib/error.js.) But probably this is not very discoverable and there might be other places where this information is missing?

1reaction
jheckingcommented, Apr 20, 2021

The referenced client object should be the same. Let me know if calling client.close() does not release all event loop handles either in your case. Btw, what client version are you using?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Open handle keeps Jest from exiting ( TCPSERVERWRAP)
Jest has detected the following 1 open handle potentially keeping Jest from exiting: ○ TCPSERVERWRAP 27 | test('The GET /status route ...
Read more >
Async external function leaves open handles - Jest, Supertest ...
This open handles are generated by an external async function that is being called within my test file. I'm using an external function...
Read more >
Let It Crash: Best Practices for Handling Node.js Errors on ...
If the process crashes due to a failure, the process monitor is in charge of restarting the process. Our recommendation is to always...
Read more >
"Cannot connect the computer to the server" error message ...
Resolution. Important To fix this problem, first restart the computer. If the restart does not fix the problem, and you want us to...
Read more >
A Guide to Error Handling in Express.js | Scout APM Blog
Error handling often doesn't get the attention it deserves. Mishandled errors can lead to a bad UX and negatively affect your business.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found