Skip to content

Commit f9a5b3a

Browse files
committed
client: make connection.reconnect true by default
1 parent 36cc901 commit f9a5b3a

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

lib/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Client extends EventEmitter {
3030

3131
this.maxReconnectAttempts = _.get(this.opts.connection.maxReconnectAttempts, Infinity);
3232
this.maxReconnectInterval = _.get(this.opts.connection.maxReconnectInterval, 30000);
33-
this.reconnect = _.get(this.opts.connection.reconnect, false);
33+
this.reconnect = _.get(this.opts.connection.reconnect, true);
3434
this.reconnectDecay = _.get(this.opts.connection.reconnectDecay, 1.5);
3535
this.reconnectInterval = _.get(this.opts.connection.reconnectInterval, 1000);
3636

test/commands.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ describe('commands (justinfan)', function() {
412412
connection: {
413413
server: 'localhost',
414414
port: 7000,
415-
timeout: 1
415+
timeout: 1,
416+
reconnect: false
416417
}
417418
});
418419
});

test/websockets.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('websockets', function() {
5454
});
5555
});
5656

57-
describe('server crashed, with reconnect: false (default)', function() {
57+
describe('server crashed, with reconnect: true (default)', function() {
5858
before(function() {
5959
// Initialize websocket server
6060
this.server = new WebSocketServer({ port: 7000 });
@@ -66,7 +66,7 @@ describe('server crashed, with reconnect: false (default)', function() {
6666
});
6767
});
6868

69-
it('gracefully handle the error', function(cb) {
69+
it('attempt to reconnect', function(cb) {
7070
this.timeout(15000);
7171
const client = this.client;
7272
const server = this.server;
@@ -77,28 +77,30 @@ describe('server crashed, with reconnect: false (default)', function() {
7777
});
7878

7979
client.on('disconnected', function() {
80-
'Test that we reached this point'.should.be.ok();
81-
cb();
80+
setTimeout(function() {
81+
'Test that we reached this point'.should.be.ok();
82+
cb();
83+
}, client.reconnectTimer);
8284
});
8385

8486
client.connect().catch(catchConnectError);
8587
});
8688
});
8789

88-
describe('server crashed, with reconnect: true', function() {
90+
describe('server crashed, with reconnect: false', function() {
8991
before(function() {
9092
// Initialize websocket server
9193
this.server = new WebSocketServer({ port: 7000 });
9294
this.client = new tmi.client({
9395
connection: {
9496
server: 'localhost',
9597
port: 7000,
96-
reconnect: true
98+
reconnect: false
9799
}
98100
});
99101
});
100102

101-
it('attempt to reconnect', function(cb) {
103+
it('gracefully handle the error', function(cb) {
102104
this.timeout(15000);
103105
const client = this.client;
104106
const server = this.server;
@@ -109,10 +111,8 @@ describe('server crashed, with reconnect: true', function() {
109111
});
110112

111113
client.on('disconnected', function() {
112-
setTimeout(function() {
113-
'Test that we reached this point'.should.be.ok();
114-
cb();
115-
}, client.reconnectTimer);
114+
'Test that we reached this point'.should.be.ok();
115+
cb();
116116
});
117117

118118
client.connect().catch(catchConnectError);

0 commit comments

Comments
 (0)