Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unhandledrejection #996

Open
huineng opened this issue May 10, 2024 · 5 comments
Open

unhandledrejection #996

huineng opened this issue May 10, 2024 · 5 comments

Comments

@huineng
Copy link

huineng commented May 10, 2024

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

Nan::ThrowError("Wrong param format!");

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 pushed a commit that referenced this issue Nov 13, 2024
@bimalkjha
Copy link
Member

@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
Copy link
Author

huineng commented Nov 13, 2024

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

bimalkjha pushed a commit that referenced this issue Nov 21, 2024
 * test: add test case for issue #996 (Bimal Jha)
 * update adm-zip version, fix of issue #991 (Bimal Jha)
 * add support for nodev23.x (Bimal Jha)
 * add support for nodev22.x on Windows #1005 (Bimal Jha)
 * Update README.md doc for issue #1004 (Bimal Kumar Jha)
 * Axios upgrade due open vulnerability [CVE-2024-39338] (#1001) (Iván Gustavo Ortiz García)
 * upd: nan version to 2.20.0 (Bimal Jha)
 * fea: add binaries for electron_v31 (Bimal Jha)
 * update nan version (Bimal Jha)
 * update mac binaries for electron 28 (Bimal Jha)
 * fix adm-zip version temporarily to fix vscode install issue (Bimal Jha)
 * Add Linux and Windows binaries for electron version 28 (Bimal Jha)
 * doc: update info about JKS file for SSL Connection (Bimal Jha)
@bimalkjha
Copy link
Member

@huineng Are you able to reproduce your error using a simple test program? If not, please try making small test program. Then you can collect db2traces and we can look into trace file that which API is throwing CLI0123E error.
Also, you can install ibm_db in debug mode and run your test program, which will print API call sequence on screen and we can see from where error is comming.

If you can repro using small test program, try below commands to collect logs:

cd ..../ibm_db/installer
source ./setenv.sh
cd ..
npm install --debug
cd test
./trace test-async-await.js

Capture all output of test program to a file and zip the output file along with other generated 1.* file. You can attach zip file here.
If issue is reproducible only using your application, still you can build ibm_db using --debug option and run your test program. In debug mode, you can see lots of output of screen that you can analyze to find the root cause. Thanks.

@bimalkjha
Copy link
Member

@huineng Any update? Can we close the issue? Thanks.

@huineng
Copy link
Author

huineng commented Dec 11, 2024

Hi Bimal, so i ran your test

but i first added this line at the top of the file

process
  .on('unhandledRejection', async (reason, p) => {
    console.debug('unhandled', reason, p)
  })

main();
async function main() {

and this was the result

Got error, throwing it.
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 test3 (/workspaces/dsw-dashboard/node_modules/ibm_db/test/test-asyc-await.js:73:18)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async main (/workspaces/dsw-dashboard/node_modules/ibm_db/test/test-asyc-await.js:22:5)
unhandled [Error: [IBM][CLI Driver] CLI0123E  SQL data type out of range. SQLSTATE=HY004] {
  error: '[ibm_db] SQL_ERROR',
  sqlcode: -99999,
  state: 'HY004',
  resultset: []
} Promise {
  promiseDispatch: [Function (anonymous)],
  inspect: [Function: inspect],
  exception: [Error: [IBM][CLI Driver] CLI0123E  SQL data type out of range. SQLSTATE=HY004] {
    error: '[ibm_db] SQL_ERROR',
    sqlcode: -99999,
    state: 'HY004',
    resultset: []
  },
  valueOf: [Function (anonymous)]
}

hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants