node-mssql: Exception on ConnectionPool release
I’m getting a uncaught exception since I upgraded to v4. I couldn’t pinpoint from the stack trace (below) when/where exactly it’s happening.
Except for the v3 to v4 migration, I didn’t change anything else in my code.
TypeError: Cannot read property 'release' of null
at ConnectionPool.release (/app/node_modules/mssql/lib/base.js:199:14)
at Request.tds.Request.err [as userCallback] (/app/node_modules/mssql/lib/tedious.js:608:25)
at Request._this.callback (/app/node_modules/tedious/lib/request.js:47:27)
at Connection.message (/app/node_modules/tedious/lib/connection.js:1401:27)
at Connection.dispatchEvent (/app/node_modules/tedious/lib/connection.js:687:45)
at MessageIO.<anonymous> (/app/node_modules/tedious/lib/connection.js:602:18)
at emitNone (events.js:86:13)
at MessageIO.emit (events.js:186:7)
at ReadablePacketStream.<anonymous> (/app/node_modules/tedious/lib/message-io.js:102:16)
at emitOne (events.js:96:13)
at ReadablePacketStream.emit (events.js:189:7)
Hope you’ll be able to help, thanks!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 18
I am having the same issue.
I’m testing the following to bypass the error, so far so good:
The error might come from the
_closemethod:https://github.com/patriksimek/node-mssql/blob/85c14ff5b01b1ae0575591c7e4f1c7327cf82e51/lib/base.js#L299-L311
this.poolis set tonulljust after callingthis.pool.drain(), sodrain()isn’t done yet. I suspectdrain()to cause requests to error, reaching the following:https://github.com/patriksimek/node-mssql/blob/85c14ff5b01b1ae0575591c7e4f1c7327cf82e51/lib/tedious.js#L455 which calls https://github.com/patriksimek/node-mssql/blob/85c14ff5b01b1ae0575591c7e4f1c7327cf82e51/lib/base.js#L197
but at this point
this.poolhas been set tonull.Moving
this.pool = nullinsidedrain's callback might have unwanted side-effects, so I won’t open a PR for it but @patriksimek might enlighten us.