Skip to content

Commit

Permalink
Revert "refactor: emit client connect in next tick during testing"
Browse files Browse the repository at this point in the history
This reverts commit 5efb887.
  • Loading branch information
enisdenjo committed Feb 1, 2023
1 parent 5efb887 commit c10d0bf
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/__tests__/utils/tservers.ts
Expand Up @@ -218,7 +218,6 @@ export async function startWSTServer(
const pendingClients: TServerClient[] = [];
wsServer.on('connection', (client) => {
pendingClients.push(toClient(client));
setTimeout(() => emitter.emit('client'), 0);
client.once('close', () => {
pendingCloses++;
emitter.emit('close');
Expand Down Expand Up @@ -254,10 +253,10 @@ export async function startWSTServer(
resolve();
}
if (pendingClients.length > 0) return done();
emitter.once('client', done);
wsServer.once('connection', done);
if (expire)
setTimeout(() => {
emitter.off('client', done); // expired
wsServer.off('connection', done); // expired
resolve();
}, expire);
});
Expand Down Expand Up @@ -507,7 +506,6 @@ export async function startFastifyWSTServer(
fastify.get(path, { websocket: true }, (connection, request) => {
sockets.add(connection.socket);
pendingClients.push(toClient(connection.socket));
setTimeout(() => emitter.emit('client'), 0);
connection.socket.once('close', () => {
sockets.delete(connection.socket);
pendingCloses++;
Expand Down Expand Up @@ -586,10 +584,10 @@ export async function startFastifyWSTServer(
resolve();
}
if (pendingClients.length > 0) return done();
emitter.once('client', done);
fastify.websocketServer.once('connection', done);
if (expire)
setTimeout(() => {
emitter.off('client', done); // expired
fastify.websocketServer.off('connection', done); // expired
resolve();
}, expire);
});
Expand Down

0 comments on commit c10d0bf

Please sign in to comment.