diff --git a/packages/socket-mode/test/integration.spec.js b/packages/socket-mode/test/integration.spec.js index 51493cffb..e6b74ca0e 100644 --- a/packages/socket-mode/test/integration.spec.js +++ b/packages/socket-mode/test/integration.spec.js @@ -205,7 +205,7 @@ describe('Integration tests with a WebSocket server', () => { // crucially, the bug reported in https://github.com/slackapi/node-slack-sdk/issues/2094 shows that on every reconnection attempt, we spawn _another_ websocket instance, which attempts to reconnect forever and is never cleaned up. // effectively: with each reconnection attempt, we double the number of websockets, eventually causing crashes / out-of-memory issues / rate-limiting from Slack APIs. // with the bug not fixed, this assertion fails as `close` event was emitted 4 times! if we waited another 20ms, we would see this event count double again (8), and so on. - assert.equal(closed, 2, 'unexpected number of times `close` event was raised during reconnection!'); + const retries = closed; await client.disconnect(); await new Promise((res, rej) => { // shut down the bad server @@ -214,6 +214,7 @@ describe('Integration tests with a WebSocket server', () => { else res(); }); }); + assert.equal(retries, 2, 'unexpected number of times `close` event was raised during reconnection!'); }); }); describe('lifecycle events', () => {