diff --git a/src/client.ts b/src/client.ts index e87d1ad2..1ac156fc 100644 --- a/src/client.ts +++ b/src/client.ts @@ -258,13 +258,6 @@ export function createClient(options: ClientOptions): Client { listener(...args); } }, - reset() { - (Object.keys(listeners) as (keyof typeof listeners)[]).forEach( - (event) => { - listeners[event] = []; - }, - ); - }, }; })(); @@ -554,7 +547,6 @@ export function createClient(options: ClientOptions): Client { const socket = await connecting; socket.close(1000, 'Normal Closure'); } - emitter.reset(); }, }; } diff --git a/src/tests/client.ts b/src/tests/client.ts index 3f235695..ea9f8d7a 100644 --- a/src/tests/client.ts +++ b/src/tests/client.ts @@ -1029,4 +1029,22 @@ describe('events', () => { expect(cal[0]).toHaveProperty('wasClean'); }); }); + + it('should emit closed event when disposing', async (done) => { + const { url, waitForClient } = await startTServer(); + + const client = createClient({ + url, + lazy: false, + retryAttempts: 0, + onNonLazyError: noop, + on: { + closed: () => done(), + }, + }); + + await waitForClient(); + + client.dispose(); + }); });