Skip to content

Commit

Permalink
Work-around socket.connect bug in Node 7.7.2
Browse files Browse the repository at this point in the history
Node 7.7.2 introduced a bug in socket.connect, where you get an error:
typeerror: "listener" argument must be a function

Switched to net.connect which does not have this bug.
  • Loading branch information
tvrprasad committed Mar 10, 2017
1 parent fba751f commit b7adbea
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Request = require('./request');
const RpcRequestPayload = require('./rpcrequest-payload');
const SqlBatchPayload = require('./sqlbatch-payload');
const MessageIO = require('./message-io');
const Socket = require('net').Socket;
const net = require('net');
const TokenStreamParser = require('./token/token-stream-parser').Parser;
const Transaction = require('./transaction').Transaction;
const ISOLATION_LEVEL = require('./transaction').ISOLATION_LEVEL;
Expand Down Expand Up @@ -508,15 +508,14 @@ class Connection extends EventEmitter {
}

connectOnPort(port) {
this.socket = new Socket({});
const connectOpts = {
host: this.routingData ? this.routingData.server : this.config.server,
port: this.routingData ? this.routingData.port : port
};
if (this.config.options.localAddress) {
connectOpts.localAddress = this.config.options.localAddress;
}
this.socket.connect(connectOpts);
this.socket = net.connect(connectOpts);
this.socket.on('error', this.socketError);
this.socket.on('connect', this.socketConnect);
this.socket.on('close', this.socketClose);
Expand Down

0 comments on commit b7adbea

Please sign in to comment.