Errors are swallowed
See original GitHub issueHi, 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:
- Created 3 years ago
- Comments:18 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 bysql.end()
being pending forever if something held the tcp connection open. For this use case it was better to usesocket.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 thesql.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 😂
Very cool! Glad we were able to help/host 😜