TimelordUK / node-sqlserver-v8

branched from node-sqlserver, SQL server driver compatible with all versions of Node
Other
135 stars 43 forks source link

uncaughtException: Cannot read properties of null (reading 'query') #317

Open nqb9 opened 7 months ago

nqb9 commented 7 months ago

Hello, unfortunately I got an uncaught exception in my application. I was using a pool to query SQL Server database multiple times, also with pause and cancel query, and got the problem: image

It is on the line 646 in lib/pool.js

The description.connection is null and look like it is set to null only in this place: image

My msnodesqlv8 version: 4.1.1

Looking forward to your response. Thank you.

nqb9 commented 7 months ago

The whole error log is: TypeError: Cannot read properties of null (reading 'query') at heartbeat (C:\IMS-PROJECTS\QA\QService\node_modules\msnodesqlv8\lib\pool.js:646:42) at Timeout._onTimeout (C:\IMS-PROJECTS\QA\QService\node_modules\msnodesqlv8\lib\pool.js:593:15) at listOnTimeout (node:internal/timers:561:11) at processTimers (node:internal/timers:502:7) { "error": {}, "stack": "TypeError: Cannot read properties of null (reading 'query')\n at heartbeat (C:\\IMS-PROJECTS\\QA\\QService\\node_modules\\msnodesqlv8\\lib\\pool.js:646:42)\n at Timeout._onTimeout (C:\\IMS-PROJECTS\\QA\\QService\\node_modules\\msnodesqlv8\\lib\\pool.js:593:15)\n at listOnTimeout (node:internal/timers:561:11)\n at processTimers (node:internal/timers:502:7)", "exception": true, "date": "Mon Dec 18 2023 14:52:18 GMT+0700 (Indochina Time)", "process": { "pid": 2740, "uid": null, "gid": null, "cwd": "C:\\IMS-PROJECTS\\QA\\QService", "execPath": "C:\\Program Files\\nodejs\\node.exe", "version": "v16.19.0", "argv": [ "C:\\Program Files\\nodejs\\node.exe", "C:\\IMS-PROJECTS\\QA\\QService\\dist\\server\\src\\index.js", "--logLevel", "debug" ], "memoryUsage": { "rss": 431636480, "heapTotal": 349945856, "heapUsed": 346579832, "external": 20484001, "arrayBuffers": 18993878 } }, "os": { "loadavg": [ 0, 0, 0 ], "uptime": 369710 }, "trace": [ { "column": 42, "file": "C:\\IMS-PROJECTS\\QA\\QService\\node_modules\\msnodesqlv8\\lib\\pool.js", "function": "heartbeat", "line": 646, "method": null, "native": false }, { "column": 15, "file": "C:\\IMS-PROJECTS\\QA\\QService\\node_modules\\msnodesqlv8\\lib\\pool.js", "function": "Timeout._onTimeout", "line": 593, "method": "_onTimeout", "native": false }, { "column": 11, "file": "node:internal/timers", "function": "listOnTimeout", "line": 561, "method": null, "native": false }, { "column": 7, "file": "node:internal/timers", "function": "processTimers", "line": 502, "method": null, "native": false } ] }

TimelordUK commented 7 months ago

im not sure when I can look at this, i current;y have little time available

it would seem we somehow are closing the connection as part of considering it idle but leaving the description with its connection marked null.

do we still see the problem if we set inactivityTimeoutSecs

to be very high so connections in pool are always held open?

nqb9 commented 7 months ago

Thank you very much for the response and happy holidays!

I tried with inactivityTimeoutSecs = 60 (from the src it seems 60 is the max value allowed), but unfortunately I still got problem after some queries.

The problem is not the exact same as above, but still the description.connection is null, which leads to the error

log "stack":"TypeError: Cannot read properties of null (reading 'query')\n at getTheQuery (D:\\IMS\\Repos\\QService\\node_modules\\msnodesqlv8\\lib\\pool.js:321:28)\n at item (D:\\IMS\\Repos\\QService\\node_modules\\msnodesqlv8\\lib\\pool.js:338:19)\n at D:\\IMS\\Repos\\QService\\node_modules\\msnodesqlv8\\lib\\pool.js:389:15","message":"Cannot read properties of null (reading 'query')"

src from log image image image