ibmdb / node-ibm_db

IBM DB2 and IBM Informix bindings for node
MIT License
192 stars 150 forks source link

unhandledrejection #996

Open huineng opened 6 months ago

huineng commented 6 months ago

ibm_db 3.2.4. node 20.12.2

i was doing some development as usual using some try { await conn.query(sql,bindings) } catch (err) { throw err} (or Promise.reject)

the problem was that i by mistake provided for bindings [['string']] instead of ['string']

So i got my rejecting and this had a message like

stack: Error: Wrong param format!
   at /node_modules/ibm_db/lib/odbc.js:677:19
   at SimpleQueue.next (/node_modules/ibm_db/lib/simple-queue.js:34:5)
   at SimpleQueue.maybeNext (/node_modules/ibm_db/lib/simple-queue.js:22:10)
   at SimpleQueue.push (/node_modules/ibm_db/lib/simple-queue.js:15:8)
   at Database.query (/node_modules/ibm_db/lib/odbc.js:520:14)

i guess this is from this line https://github.com/ibmdb/node-ibm_db/blob/a2f0018a74f076832c569f38af7ba2b6b7e73553/src/odbc.cpp#L988

fine

But then i got also a unhandledrejection with reason

reason: Error: [IBM][CLI Driver] CLI0123E  SQL data type out of range. SQLSTATE=HY004

so it looks to me the code doesn't stop at the first error

thanks

bimalkjha commented 1 week ago

@huineng I tried to repro the issue on my Linux system using latest code of ibm_db and latest version of nodejs. But, I am unable to reproduce it. So, added a test case too. Could you please install latest code from git and run test file test-asyc-await.js to verify it? If issue is still reproducible for you, please share simple test program to reproduce it.

When I run the latest updated test-async-await.js file, getting output as below for Test3:

Test for issue #960 is done.
Got error, throwing it.
Error: Wrong param format!
    at /home/bjha/nodework/master/node-ibm_db/lib/odbc.js:677:19
    at SimpleQueue.next (/home/bjha/nodework/master/node-ibm_db/lib/simple-queue.js:34:5)
    at SimpleQueue.maybeNext (/home/bjha/nodework/master/node-ibm_db/lib/simple-queue.js:22:10)
    at SimpleQueue.push (/home/bjha/nodework/master/node-ibm_db/lib/simple-queue.js:15:8)
    at Database.query (/home/bjha/nodework/master/node-ibm_db/lib/odbc.js:520:14)
    at test3 (/home/bjha/nodework/master/node-ibm_db/test/test-asyc-await.js:80:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async main (/home/bjha/nodework/master/node-ibm_db/test/test-asyc-await.js:12:5)
Test3 done.

Thanks.

huineng commented 1 week ago

thanks Bimal for you rapid answer :)

i still have the unhandled rejection and doing a debug i get the same as you

Error: Wrong param format!
    at /workspaces/dsw-dashboard/node_modules/ibm_db/lib/odbc.js:677:19
    at SimpleQueue.next (/workspaces/dsw-dashboard/node_modules/ibm_db/lib/simple-queue.js:34:5)
    at SimpleQueue.maybeNext (/workspaces/dsw-dashboard/node_modules/ibm_db/lib/simple-queue.js:22:10)
    at SimpleQueue.push (/workspaces/dsw-dashboard/node_modules/ibm_db/lib/simple-queue.js:15:8)
    at Database.query (/workspaces/dsw-dashboard/node_modules/ibm_db/lib/odbc.js:520:14)
    at Db2.runQuery (/workspaces/dsw-dashboard/server/server.js:2256:37)

but my unhandled rejection is trowing a different message

[ibm_db] SQL_ERROR","sqlcode":-99999,"message":"[IBM][CLI Driver] CLI0123E  SQL data type out of range. SQLSTATE=HY004","state":"HY004","resultset":[]}

where is that message coming from ?

You are running a file, i run a webserver with node that has a specific .on('unhandledRejection') handler maybe that might explain ?

Thanks