Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 22adb45

Browse filesBrowse files
committed
Make sure to catch all stream errors on connect
It seems like some stream errors may occur sync, so one has to attach an error listener to the stream before executing `connect`. I'm not sure if this is how things should behave, will clarify with Ryan.
1 parent 99cad60 commit 22adb45
Copy full SHA for 22adb45

File tree

Expand file treeCollapse file tree

2 files changed

+6
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-6
lines changed

‎lib/mysql/client.js

Copy file name to clipboardExpand all lines: lib/mysql/client.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ Client.prototype.connect = function(cb) {
4848
var connection = self._connection = new Stream(),
4949
parser = self._parser = new Parser();
5050

51-
connection.connect(self.port, self.host);
5251
connection
5352
.on('error', function(err) {
5453
if (err.errno & (netBinding.ECONNREFUSED | netBinding.ENOTFOUND)) {
@@ -77,6 +76,7 @@ Client.prototype.connect = function(cb) {
7776
self.connected = false;
7877
self._prequeue(connect);
7978
});
79+
connection.connect(self.port, self.host);
8080

8181
parser
8282
.on('packet', function(packet) {

‎test/simple/test-client.js

Copy file name to clipboardExpand all lines: test/simple/test-client.js
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ test(function connect() {
7474
gently.expect(StreamStub, 'new', function() {
7575
CONNECTION = this;
7676

77-
gently.expect(CONNECTION, 'connect', function(port, host) {
78-
assert.equal(port, client.port);
79-
assert.equal(host, client.host);
80-
});
81-
8277
var events = ['error', 'data', 'end'];
8378
gently.expect(CONNECTION, 'on', events.length, function(event, fn) {
8479
assert.equal(event, events.shift());
8580
onConnection[event] = fn;
8681
return this;
8782
});
83+
84+
gently.expect(CONNECTION, 'connect', function(port, host) {
85+
assert.equal(port, client.port);
86+
assert.equal(host, client.host);
87+
});
8888
});
8989

9090
gently.expect(ParserStub, 'new', function() {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.