Node-mssql: TDS event error - "No event 'socketConnect' in state 'Final'"

Created on 28 Mar 2016  路  11Comments  路  Source: tediousjs/node-mssql

Had an error show up randomly today while a user was working with our application - on investigating the logs, it looks like this popped up:

Mon Mar 28 2016 18:54:24 GMT+0000 (Coordinated Universal Time): Uncaught exception: Error: No event 'socketConnect' in state 'Final'
at Connection.dispatchEvent ([...]mssql\node_modules\tedious\lib\connection.js:561:28)
at Connection.socketConnect ([...]mssql\node_modules\tedious\lib\connection.js:585:19)
at Socket.emit (events.js:129:20)
at TCPConnectWrap.afterConnect as oncomplete

This seems to have been reported as an error on the TDS github repo as well so I'm going to dig through that thread in more detail. I have created this report since it could be MSSQL's wrapping of TDS causing the issue vs. TDS itself.

bug unconfirmed

Most helpful comment

I am also having this issue. [email protected]

All 11 comments

What version of mssql do you use? Could you please post the link to the reported error you found?

The mssql version is 3.1.1. The TDS error report is at https://github.com/pekim/tedious/issues/185 though I have gotten caught up with work again and didn't get a chance to properly read the outcome.

The error is telling us that the socket was open on a previously closed connection. I don't think I can help here without a code to reproduce the issue.

It may be worth closing the issue for now in this case - I have yet to see the error re-occur despite running the code for a considerable amount of time. It may be a one-off - I will keep an eye out and see if it ever arises in future.

Helo, i've get a same problem when connection to server was end by timeout.
to test this bug i set connectionTimeout to 1 ms.
I solved this like that:
to tedoius\lib\connection.js
I add event wich throw error. in Connection.prototype.STATE.FINAL

socketConnect: function socketError() {
// Do nothing
// added by my, here was an error where connection was closed by timeout
}

@iseekyouu

Could you clarify on what your fix here was and whether it was successful in solving the issue?

We can confirm, the error still shows up even when using latest version mf node-mssql ([email protected], [email protected], [email protected])

Error: No event 'socketConnect' in state 'Final'
     at Connection.dispatchEvent ([...]/mssql/node_modules/tedious/lib/connection.js:859:28)
     at Connection.socketConnect ([...]/mssql/node_modules/tedious/lib/connection.js:883:19)
     at [...]/mssql/node_modules/tedious/lib/connection.js:755:16
     at Socket.onConnect ([...]/mssql/node_modules/tedious/lib/connector.js:176:9)
     at emitNone (events.js:67:13)
     at Socket.emit (events.js:166:7)
     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1068:10)

I was able to reliable reproduce the problem by setting the connectionTimeout=1.

I am also having this issue. [email protected]

Same problem here at our production environment. It seems that it is somehow related to the ConnectionError, which occurs at least twice a day.

2018-04-27T02:30:30.892031434Z error:  ConnectionError: Failed to connect to xxx.database.windows.net:1433 in 15000ms
2018-04-27T02:30:30.892063934Z     at Connection.tedious.once.err (/usr/src/app/node_modules/mssql/lib/tedious.js:227:17)
2018-04-27T02:30:30.892070634Z     at Object.onceWrapper (events.js:272:13)
2018-04-27T02:30:30.892075334Z     at Connection.emit (events.js:180:13)
2018-04-27T02:30:30.892079934Z     at Connection.connectTimeout (/usr/src/app/node_modules/tedious/lib/connection.js:619:12)
2018-04-27T02:30:30.892084734Z     at ontimeout (timers.js:466:11)
2018-04-27T02:30:30.892089234Z     at tryOnTimeout (timers.js:304:5)
2018-04-27T02:30:30.892101134Z     at Timer.listOnTimeout (timers.js:267:5)
2018-04-27T02:30:31.157162711Z error: Process uncaughtException event was triggered: 
2018-04-27T02:30:31.157231412Z Error: No event 'socketConnect' in state 'Final'

did anyone tried this specific version of tedious mentioned in the newer bug issue:

https://github.com/tediousjs/tedious/issues/683

This has been resolved in Tedious and released in this library's own dependency.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryankelley picture ryankelley  路  4Comments

sizovilya picture sizovilya  路  3Comments

linvi picture linvi  路  3Comments

mhunting picture mhunting  路  6Comments

PatrikFomin picture PatrikFomin  路  6Comments