Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

#142 - Fix ReferenceError in instance lookup error handler

  • Loading branch information...
commit 36cb355ce0959434739f14e4d643cea1d9f5b2da 1 parent ecb19d8
@patriksimek patriksimek authored
View
2  package.json
@@ -26,7 +26,7 @@
"url": "https://raw.github.com/pekim/tedious/master/LICENSE"
}
],
- "version": "0.2.1",
+ "version": "0.2.2",
"main": "./lib/tedious.js",
"repository": {
"type": "git",
View
6 src/connection.coffee
@@ -353,8 +353,8 @@ class Connection extends EventEmitter
if (@config.options.port)
@connectOnPort(@config.options.port)
else
- instanceLookup(@config.server, @config.options.instanceName, (err, port) =>
- if err
+ instanceLookup(@config.server, @config.options.instanceName, (message, port) =>
+ if message
@emit('connect', ConnectionError(message, 'EINSTLOOKUP'))
else
@connectOnPort(port)
@@ -378,7 +378,7 @@ class Connection extends EventEmitter
)
closeConnection: ->
- @socket.destroy()
+ @socket?.destroy()
createConnectTimer: ->
@connectTimer = setTimeout(@connectTimeout, @config.options.connectTimeout)
View
33 test/integration/connection-test.coffee
@@ -149,6 +149,39 @@ exports.connectByInstanceName = (test) ->
#console.log(text)
)
+exports.connectByInvalidInstanceName = (test) ->
+ if !getInstanceName()
+ # Config says don't do this test (probably because SQL Server Browser is not available).
+ console.log('Skipping connectByInvalidInstanceName test')
+ test.done()
+ return
+
+ test.expect(1)
+
+ config = getConfig()
+ delete config.options.port
+ config.options.instanceName = "#{getInstanceName()}X"
+
+ connection = new Connection(config)
+
+ connection.on('connect', (err) ->
+ test.ok(err)
+
+ connection.close()
+ )
+
+ connection.on('end', (info) ->
+ test.done()
+ )
+
+ connection.on('infoMessage', (info) ->
+ #console.log("#{info.number} : #{info.message}")
+ )
+
+ connection.on('debug', (text) ->
+ #console.log(text)
+ )
+
exports.encrypt = (test) ->
test.expect(5)
Please sign in to comment.
Something went wrong with that request. Please try again.