Trying to query without prior connect should throw an error
See original GitHub issueI 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:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top 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 >
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 Free
Top 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
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.
This burned me pretty bad today.
It appears if you call
client.query()
before you callclient.connect()
, this queues up a query to be executed whenever you may happen to callclient.connect()
in the future. If you forgot to callclient.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.