문제 인식

여러 플레이어가 동시에 같은 몬스터를 처치했을 때 문제가 발생했습니다.

🚫 문제점

원인 파악

onData 코드

const headerSize = headerConstants.TOTAL_LENGTH + headerConstants.PACKET_TYPE_LENGTH;

const onData = (socket) => async (data) => {
  try {
    socket.buffer = Buffer.concat([socket.buffer, data]);
    while (socket.buffer.length >= headerSize) {
      const { totalLength, packetType } = readHeader(socket.buffer);
      if (totalLength > socket.buffer.length) {
        break;
      }
      const packet = socket.buffer.subarray(headerSize, totalLength);
      socket.buffer = socket.buffer.subarray(totalLength);
		
			...
    }
  } catch (err) {
    handleError(socket, err);
  }
};

🔍 분석

해결 과정

Bull Queue 구현

게임 서버 로직 비동기 처리

결론

✅ Bull Queue 적용 및 게임 서버 로직 비동기 처리로 해결