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.

Trying to query without prior connect should throw an error

See original GitHub issue

I forgot to connect with client.connect() and spent more time than I should’ve when my queries silently failed.

Should an error be thrown when trying to use query without prior connect?

If so, I could probably whip up a PR.

Thanks!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
brianccommented, Nov 25, 2019

I agree the query queue is weird…it’s very old. I think I based it on the original design of the mysql lib which has also undergone extensive changes throughout the years. I’m in favor of removing it as well…it seemed like a good idea at the time, but it wasn’t. It’s just a weird artifact from long ago. Obviously a breaking change to remove it, but probably wont bite that much since like you I doubt many people use it other than accidentally.

1reaction
accocommented, Nov 24, 2019

This burned me pretty bad today.

It appears if you call client.query() before you call client.connect(), this queues up a query to be executed whenever you may happen to call client.connect() in the future. If you forgot to call client.connect() (an honest mistake), this means you get back a promise that just never resolves.

This should really throw an error though. There is no connection to perform a query over. The intended feature of enqueuing queries to be performed after an upcoming connection event should reside under a different method, like enqueueQuery(). It’s asking the client to perform a different sort of job. And I have to imagine this feature is only rarely used as intended.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I raise error if the execution of an SQL Query is not ...
I'm trying to raise a timeout error in my SQL Server query using c#. ... Also, you should be disposing connection, command and...
Read more >
4 Errors and Exception Handling
'); > END; > / Your SELECT statement retrieved multiple rows. Consider using a cursor. PL/SQL procedure successfully completed. Exception types. There are...
Read more >
Troubleshoot query time-out errors - SQL Server
This article describes how to troubleshoot the time-out errors when you run slow-running queries.
Read more >
Exceptions - Manual
Normal execution (when no exception is thrown within the try block) will continue after that last catch block defined in sequence. Exceptions can...
Read more >
SQL SERVER - Timeout expired. The timeout period elapsed ...
If any request is in progress and it couldn't complete within the timeout period, we would again see an error. Connection Timeout: The...
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