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

socketConnect event after connection timeout #683

Closed
hellivan opened this issue Jan 13, 2018 · 3 comments
Closed

socketConnect event after connection timeout #683

hellivan opened this issue Jan 13, 2018 · 3 comments

Comments

@hellivan
Copy link

Node version: 8.7.0
Tedious version: 2.1.5

When connecting to a database, it is possible that a 'socketConnect' event is emitted even after the connection had already timed out. As a result we get a unhandled exception that crashes the whole node application:

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)

The error can be reliably reproduced be setting the connectTimout to 1 ms.

A possible solution for this problem would be to check the connection state (if it already transitioned to state FINAL) just before calling socketConnect.

@hellivan
Copy link
Author

#682 already provides a fix for this issue.

@arthurschreiber
Copy link
Collaborator

A fix for this was just released as part of [email protected] (currently still tagged as next).

You can give it a try by doing npm install [email protected] or npm install tedious@next. Please let us know if you run into any issues.

If we don't hear back from you or anyone else regarding any issues with [email protected], it will be tagged as latest soon! 👍

@arthurschreiber
Copy link
Collaborator

As we haven't heard back so far, I tagged 2.2.4 as latest:

$ npm dist-tag add [email protected] latest
+latest: [email protected]

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