Mid-Level
August 19, 2026

Spot the bug: Node.js / NestJS

One snippet. Find the bug, or prove there isn't one.

typescript
1import { WebSocketGateway, SubscribeMessage, MessageBody, ConnectedSocket } from '@nestjs/websockets';
2import { Socket } from 'socket.io';
3import { MessagesService } from './messages.service';
4
5@WebSocketGateway({ namespace: 'chat' })
6export class ChatGateway {
7  constructor(private readonly messages: MessagesService) {}
8
9  @SubscribeMessage('joinRoom')
10  async joinRoom(
11    @ConnectedSocket() client: Socket,
12    @MessageBody() data: { roomId: string },
13  ) {
14    client.join(data.roomId);
15    const history = await this.messages.getRoomHistory(data.roomId);
16    client.emit('history', history);
17  }
18}

Click the lines that carry the problem.

Your verdict

One attempt per day. The answer shows up right after.

Keep your streak

Create an account to keep your streak and track your progress.

Create an account