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.

Can't catch prepared statement failure

See original GitHub issue
const ps = new sql.PreparedStatement()
ps.input('param', sql.Int)
ps.prepare('select non-exisiting-column from table_name where phone = @phone')
.then(() => {
    // fails with uncaughtException, never happens
}).catch(er => console.error(e)) // never happens

Fails with uncaughtException Tried with plain promises and async/await

[Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Statement(s) could not be prepared.] {
  sqlstate: '42000',
  code: 8180
}
"mssql": "^6.0.1"
"msnodesqlv8": "^0.8.6",
SQL Server 2016

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
dhensbycommented, Jan 22, 2020

My conclusion is that msnodesqlv8 is emitting multiple error events under this scenario, this is a very difficult situation to handle as really we’d expect a connection to have a 1-1 query to error output. If a connection can output many errors then we don’t know when we can expect the errors to stop coming and when the connection can be safely released back to the pool.

I’m going to open an issue with the driver and see if I can get any advice. see https://github.com/TimelordUK/node-sqlserver-v8/issues/133

0reactions
dhensbycommented, Mar 18, 2020

Fixed with #981

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prepared Statement Failing - java - Stack Overflow
I am using one that deletes data that works fine, but the insert one is not inserting any data into the data table...
Read more >
Prepared Statements - Manual - PHP
A prepared statement can be executed repeatedly. Upon every execution the current value of the bound variable is evaluated and sent to the...
Read more >
PREPARE Statement - MariaDB Knowledge Base
This means that if the new statement contains an error and cannot be prepared, an error is returned and no statement with the...
Read more >
General error: 1615 Prepared statement needs to be re ...
This means when the parameters are passed to the query, attempts to inject SQL into them are blocked, since MySQL prepared statements are...
Read more >
(The only proper) PDO tutorial - Treating PHP Delusions
Prepared statement is the only proper way to run a query, if any variable is going to be used in it. The reason...
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