Skip to content

Commit e1ea765

Browse files
committed
test(socket-mode): avoid rushing reconnect attempts
1 parent 6e161be commit e1ea765

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

packages/socket-mode/test/integration.test.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe('Integration tests with a WebSocket server', { timeout: 30000 }, () =>
9999
clientOptions: {
100100
slackApiUrl: `http://localhost:${HTTP_PORT}/`,
101101
},
102-
clientPingTimeout: 25,
102+
clientPingTimeout: 100,
103103
});
104104
});
105105
it('should retry if retrieving a WSS URL fails', async () => {
@@ -140,6 +140,7 @@ describe('Integration tests with a WebSocket server', { timeout: 30000 }, () =>
140140
clientOptions: {
141141
slackApiUrl: `http://localhost:${HTTP_PORT}/`,
142142
},
143+
clientPingTimeout: 100,
143144
logLevel: 'debug',
144145
logger: {
145146
debug: debugLoggerSpy,
@@ -185,7 +186,7 @@ describe('Integration tests with a WebSocket server', { timeout: 30000 }, () =>
185186
clientOptions: {
186187
slackApiUrl: `http://localhost:${HTTP_PORT}/`,
187188
},
188-
clientPingTimeout: 20, // controls reconnection rate
189+
clientPingTimeout: 100, // controls reconnection rate
189190
logLevel: 'debug',
190191
});
191192
// shut down the default mock WS server used in these tests as we will customize its behaviour in this test
@@ -249,7 +250,7 @@ describe('Integration tests with a WebSocket server', { timeout: 30000 }, () =>
249250
clientOptions: {
250251
slackApiUrl: `http://localhost:${HTTP_PORT}/`,
251252
},
252-
clientPingTimeout: 25,
253+
clientPingTimeout: 100,
253254
});
254255
});
255256
it('raises connecting event during `start()`', async () => {
@@ -310,7 +311,9 @@ describe('Integration tests with a WebSocket server', { timeout: 30000 }, () =>
310311
});
311312
});
312313
afterEach(async () => {
313-
await client.disconnect();
314+
if (client) {
315+
await client.disconnect();
316+
}
314317
});
315318
// These tests check that specific type:disconnect events, of various reasons, sent by Slack backend are not raised as slack_events for apps to consume.
316319
for (const reason of DISCONNECT_REASONS) {
@@ -363,8 +366,8 @@ describe('Integration tests with a WebSocket server', { timeout: 30000 }, () =>
363366
clientOptions: {
364367
slackApiUrl: `http://localhost:${HTTP_PORT}/`,
365368
},
366-
clientPingTimeout: 25,
367-
serverPingTimeout: 25,
369+
clientPingTimeout: 100,
370+
serverPingTimeout: 100,
368371
pingPongLoggingEnabled: false,
369372
});
370373
});
@@ -373,8 +376,8 @@ describe('Integration tests with a WebSocket server', { timeout: 30000 }, () =>
373376
// create a waiter for post-reconnect connected event
374377
const reconnectedWaiter = new Promise((res) => client.on('connected', res));
375378
exposed_ws_connection.ping();
376-
// we set server and client ping timeout to 25, so waiting for 50 + a bit should force a reconnect
377-
await sleep(60);
379+
// we set server and client ping timeout to 100, so waiting for 200 + buffer should force a reconnect
380+
await sleep(250);
378381
// if we pass the point where the reconnectedWaiter succeeded, then we have verified the reconnection succeeded
379382
// and this test can be considered passing. if we time out here, then that is an indication of a failure.
380383
await reconnectedWaiter;
@@ -395,8 +398,8 @@ describe('Integration tests with a WebSocket server', { timeout: 30000 }, () =>
395398
await client.start();
396399
// create a waiter for post-reconnect connected event
397400
const reconnectedWaiter = new Promise((res) => client.on('connected', res));
398-
// we set server and client ping timeout to 25, so waiting for 50 + a bit should force a reconnect
399-
await sleep(60);
401+
// we set server and client ping timeout to 100, so waiting for 200 + buffer should force a reconnect
402+
await sleep(250);
400403
// if we pass the point where the reconnectedWaiter succeeded, then we have verified the reconnection succeeded
401404
// and this test can be considered passing. if we time out here, then that is an indication of a failure.
402405
await reconnectedWaiter;
@@ -426,8 +429,8 @@ describe('Integration tests with a WebSocket server', { timeout: 30000 }, () =>
426429
await client.start();
427430
// create a waiter for post-reconnect connected event
428431
const reconnectedWaiter = new Promise((res) => client.on('connected', res));
429-
// we set server and client ping timeout to 25, so waiting for 50 + a bit should force a reconnect
430-
await sleep(60);
432+
// we set server and client ping timeout to 100, so waiting for 200 + buffer should force a reconnect
433+
await sleep(250);
431434
// if we pass the point where the reconnectedWaiter succeeded, then we have verified the reconnection succeeded
432435
// and this test can be considered passing. if we time out here, then that is an indication of a failure.
433436
await reconnectedWaiter;

0 commit comments

Comments
 (0)