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.

Error handling in `Database.query` broken as of 2.4.0

See original GitHub issue

Since 2.4.0 we find that if we issue queries returning errors using the async (Promise returning) version of the Database.query method, the promise is never resolved / the error isn’t raised.

If I roll back our reference to 2.3.1 it works as expected.

        try {
            return await db.query('select 1 from sysibm.syszzzz where 1=1');
        } catch (e) {
            // on v2.4.0 this catch is never executed and nothing is returned
            console.log(e.message, e.stack);
        }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
huinengcommented, Jun 18, 2018

I used your test case promise-test-open-close as a start

var common = require("./common")
  , odbc = require("../")
  , db = new odbc.Database()
  , assert = require("assert");

//assert.equal(db.connected, false);

db.query("select * from " + common.tableName).then(null, function (err) {
  assert.deepEqual(err, { message: 'Connection not open.' });
  assert.equal(db.connected, false);
});

db.open(common.connectionString)
  .then(function (res) {
    assert.equal(db.connected, true);

    db.query("select * from " + common.tableName)
      .then(null, function (err) {
        console.log(err);
        assert.deepEqual(err, { message: 'Connection not open.' });
        assert.equal(db.connected, false);
      });

  });

i ran it agains 2.4.0

node promise-test-open-close

and " 2.3.9

node promise-test-open-close
{ Error: [IBM][CLI Driver][DB2/LINUXX8664] SQL0204N  "QFIND.NODE_ODBC_TEST_TABLE" is an undefined na
me.  SQLSTATE=42704

  errors: [],  error: '[node-ibm_db] SQL_ERROR',
  message: '[IBM][CLI Driver][DB2/LINUXX8664] SQL0204N  "QFIND.NODE_ODBC_TEST_TABLE" is an undefined
 name.  SQLSTATE=42704\n',
  state: '42S02' }

2.4.0 didn’t produce any error and stopped

in my production system this leads to a timeout

hope this helps

0reactions
huinengcommented, Aug 20, 2018

Question … why are you closing this ? the issue is not fixed, there’s no published package that contains you fix

Installing directly the github repo is not working either as this creates other problems)

thanks

for me this is a bug fix and i would suggest publishing more often bug releases

thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I catch a query exception in laravel to see if it fails?
The simplest way to catch any sql syntax or query errors is to catch an Illuminate\Database\QueryException after providing closure to your ...
Read more >
How to implement error handling in SQL Server - SQLShack
SQL Server error handling can be as simple as just logging that something happened, or it could be us trying to fix an...
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >
Best Practices - Apache Airflow
You should treat tasks in Airflow equivalent to transactions in a database. This implies that you should never produce incomplete results from your...
Read more >
What's new in django-cachalot? - Read the Docs
Fixes a very unlikely invalidation issue occurring only when an error occurred in a transaction after a transaction of another database nested in...
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