Skip to content

Commit 1585456

Browse files
committed
[dist] 0.0.6
1 parent d15e8ef commit 1585456

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#### v0.0.6
2+
- Remove the `timeout` listener, could cause double connect events / fn calls.
3+
See #10
4+
15
#### v0.0.5
26
- Adding missing `timeout` listener. See #9
37

index.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Manager.prototype.allocate = function allocate(fn) {
148148
/**
149149
* Two helper functions that allows us to correctly call the callback with
150150
* the correct arguments when we generate a new connection as the connection
151-
* should be emitting 'connect' befor we can use it. But it can also emit
151+
* should be emitting 'connect' before we can use it. But it can also emit
152152
* error if it fails to connect, or times in so doing.
153153
*
154154
* @param {Error} err Optional error argument.
@@ -166,6 +166,11 @@ Manager.prototype.allocate = function allocate(fn) {
166166
fn(err, this);
167167
}
168168

169+
/**
170+
* Listen to timeout events.
171+
*
172+
* @api private
173+
*/
169174
function timeout() {
170175
this.removeListener('timeout', timeout);
171176
self.pending--;
@@ -204,7 +209,7 @@ Manager.prototype.allocate = function allocate(fn) {
204209
// we didn't find a confident match, see if we are allowed to generate a fresh
205210
// connection
206211
if ((this.pool.length + this.pending) < this.limit) {
207-
// determin if the function expects a callback or not, this can be done by
212+
// determine if the function expects a callback or not, this can be done by
208213
// checking the length of the given function, as the amount of args accepted
209214
// equals the length..
210215
if (this.generator.length === 0) {
@@ -213,9 +218,10 @@ Manager.prototype.allocate = function allocate(fn) {
213218
if (connection) {
214219
this.pending++;
215220
this.listen(connection);
221+
216222
connection.on('error', either)
217-
.on('connect', either)
218-
.on('timeout', timeout);
223+
.on('connect', either)
224+
.on('timeout', timeout);
219225

220226
return this;
221227
}
@@ -226,9 +232,10 @@ Manager.prototype.allocate = function allocate(fn) {
226232

227233
self.pending++;
228234
self.listen(connection);
235+
229236
return connection.on('error', either)
230-
.on('connect', either)
231-
.on('timeout', timeout);
237+
.on('connect', either)
238+
.on('timeout', timeout);
232239
});
233240
}
234241
}
@@ -283,7 +290,7 @@ Manager.prototype.isAvailable = function isAvailable(net, ignore) {
283290
// The connection is still opening, so we can write to it in the future.
284291
if (readyState === 'opening') return 70;
285292

286-
// We have some writes, so we are going to substract that amount from our 100.
293+
// We have some writes, so we are going to subtract that amount from our 100.
287294
if (writes < 100) return 100 - writes;
288295

289296
// We didn't find any reliable states of the stream, so we are going to

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Arnout Kazemier <[email protected]> (http://3rd-Eden.com)",
33
"name": "jackpot",
44
"description": "Jackpot, TCP connection pooling for Node.js",
5-
"version": "0.0.5",
5+
"version": "0.0.6",
66
"homepage": "https://github.com/3rd-Eden/jackpot",
77
"main": "index.js",
88
"keywords": [

0 commit comments

Comments
 (0)