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.

Errors are swallowed

See original GitHub issue

Hi, thanks for this tool!

I’ve noticed that DB connection errors using https://github.com/porsager/postgres are swallowed. It doesn’t show anything at all.

I need to add console.log(err) to this line https://github.com/lukeed/ley/blob/master/index.js#L42 in order to see the actual error.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
porsagercommented, Oct 2, 2020

Ok, so I’ve gotten to the core of the issue now. There was actually two issues in Postgres.js which I’ve got fixed by investigating this, so thanks a lot for bringing it to my attention @frandiox and @lukeed !

The first was that I was wrongly expecting the socket to be ready before calling end() to try and end it gracefully, but it would never reach the ready state with things like connection errors.

The other was that I was using socket.end(resolve) for the end promise which would result in the promise returned by sql.end() being pending forever if something held the tcp connection open. For this use case it was better to use socket.on('close', resolve); socket.end() instead.

The reason your fix worked for this specific case was not because of rethrowing the error (which didn’t make sense to me at first), but because of removing arrayTypesPromise = null. That prevented the error popping up in the sql.end() and thereby hiding the above underlying issues.

I’ve released fixes for those issues in beta.2 now so I think this issue can also be closed 🙂

Thanks for hosting a Postgres.js issue here @lukeed 😂

0reactions
lukeedcommented, Oct 2, 2020

Very cool! Glad we were able to help/host 😜

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do programmers sometimes silently swallow exceptions?
I'm very unlikely to just silently swallow the base Exception class though, for any reason. I'd at least try to log the error....
Read more >
Swallowed Exceptions: The Silent Killer of Java Applications
How to avoid the risks of mishandling application errors? ... Swallowed exceptions are a major factor that's causing errors to go unnoticed.
Read more >
Chasing Swallowed Exceptions | Square Corner Blog
Handling uncaught errors and crashes in testing.
Read more >
How to prevent promises swallowing errors ? - GeeksforGeeks
... try to understand how we may prevent the promises swallowing errors ... then our promise will catch the error (as a Reference...
Read more >
Do Not Swallow The Exceptions | Justin James
However this is my least favorite way to not swallow exception as you are still technically swallowing the error but you can at...
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