Skip to content

Commit

Permalink
feat: change order of adding error handler and connecting functions i…
Browse files Browse the repository at this point in the history
…n redis client
  • Loading branch information
fruneen committed Dec 14, 2023
1 parent cef3ccd commit 7c7025f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions template/apps/api/src/io-emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const publish = (roomId: string | string[], eventName: string, data: unknown) =>
const initClient = async () => {
const subClient = redisClient.duplicate();

subClient.on('error', redisErrorHandler);

await subClient.connect();

subClient.on('error', redisErrorHandler);

emitter = new Emitter(subClient);
};

Expand Down
5 changes: 3 additions & 2 deletions template/apps/api/src/services/socket/socket.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ export default async (server: http.Server) => {

const subClient = pubClient.duplicate();

subClient.on('error', redisErrorHandler);

await Promise.all([pubClient.connect(), subClient.connect()]);

logger.info('Socket.io server has been connected.');

subClient.on('error', redisErrorHandler);

io.adapter(createAdapter(pubClient, subClient));

io.use(async (socket, next) => {
Expand Down

0 comments on commit 7c7025f

Please sign in to comment.