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.

Properly catching invalid connection init level errors

See original GitHub issue

createConnection connect with database as soon its called. So you can query directly like

let connection = mysql2.createConnection({});

connection.query('SELECT 1+1');

But this pose an issue, say when you pass invalid credentials. It will throw an async error which cannot be caught unless we use process.uncaughtException or domains.

Is there any way we can handle this error properly without using hacks. This is also a deviation from node-mysql API, which allow creating connections without actually connecting.

May be we should add a version of createConnection which does not connect with server unless we explicitly call connect. So if connect fails we can handle any errors properly.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
sushantdhimancommented, Jul 30, 2016

I found connect event, Let me try this

0reactions
sushantdhimancommented, Jul 30, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error handling - Apollo GraphQL Docs
OPERATION_RESOLUTION_FAILURE. The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to ...
Read more >
Handle errors in ASP.NET Core Blazor apps - Microsoft Learn
Discover how ASP.NET Core Blazor manages unhandled exceptions and how to develop apps that detect and handle errors.
Read more >
A connection was successfully established with the server, but ...
I was trying to run asp.net website in local PC, which has connection string of Production DB, following is stack trace for error...
Read more >
Get Started with Custom Error Handling in Spring Boot (Java)
Learn how to implement custom error handling logic in Spring Boot. You will see two approaches based on the @ControllerAdvice annotation.
Read more >
A Definitive Guide to Handling Errors in JavaScript - Kinsta
You could also run into this error if you forget that the said reference is a constant and use it as a variable....
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