Skip to content

fix(be): fix msg type definition for check & judge AMQP and add excep…#3574

Open
zero1177 wants to merge 2 commits into
mainfrom
t2715-fix-msg-type-in-amqp-service
Open

fix(be): fix msg type definition for check & judge AMQP and add excep…#3574
zero1177 wants to merge 2 commits into
mainfrom
t2715-fix-msg-type-in-amqp-service

Conversation

@zero1177
Copy link
Copy Markdown
Contributor

@zero1177 zero1177 commented May 22, 2026

Description

@golevelup/nestjs-rabbitmq 라이브러리 업데이트로 createSubscriber 타입 정의가 변경되어 기존 check & judge AMQP Service에 적용했습니다.

현재 라이브러리 타입 정의

type SubscriberHandler<T = unknown> = (
  msg: T | undefined,
  rawMessage?: ConsumeMessage,
  headers?: any
) => Promise<SubscribeResponse>

구체적인 변경사항

  • createSubscriber<object>() 제네릭을 추가해, subscriber가 정상적으로 수신하는 메시지의 payload 타입을 object로 명시했습니다.
  • JudgeAMQPService의 메시지 properties에 접근 시 optional chaining하도록 수정했습니다.
  • createSubscriber에 넘길 msg 처리 콜백 함수를 미리 handleJudgeMessage/handlerCheckMessage로 빼서 @golevelup/nestjs-rabbitmq 라이브러리가 제공하는 SubscriberHandler 타입을 정의해, 업데이트 된 버전에 맞는 타입 안정성을 추가했습니다.
    (전 커밋에 올렸던 raw?: ConsumeMessage로 타입을 명시하는 방식은 백엔드와 직접 Dependency가 아닌 amqplib를 import해야 해서, pnpm 환경에서 빌드가 깨질 수 있다고 해 이렇게 다시 변경했습니다)
  • msg가 undefined인 경우 예외 처리를 통해, 비어있는 judge/check 메시지를 Nack 처리하도록 추가했습니다. 이런 케이스의 메세지는 requeue하지 않는다는 의도를 명시하도록 Nack(false)로 변경했습니다.

@zero1177 zero1177 self-assigned this May 22, 2026
Copilot AI review requested due to automatic review settings May 22, 2026 04:47
@zero1177 zero1177 added the 🪰 bug Something isn't working label May 22, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the backend AMQP subscriber implementations to align with the updated @golevelup/nestjs-rabbitmq createSubscriber handler typings, and adds explicit handling for undefined message payloads in judge/check consumers.

Changes:

  • Adds createSubscriber<object>() generics and updates handler signatures to msg: T | undefined and rawMessage?: ConsumeMessage.
  • Introduces Nack handling when msg is undefined for both judge and check subscribers.
  • Uses optional access for AMQP message properties to match the library’s updated optional parameter typing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/backend/libs/amqp/src/amqp.service.ts
Comment thread apps/backend/libs/amqp/src/amqp.service.ts Outdated
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves type safety in the AMQP services by replacing 'any' with 'ConsumeMessage' and adding generic types to subscribers. It also adds validation for empty messages in both JudgeAMQPService and CheckAMQPService. The reviewer pointed out that using the default 'Nack()' for empty messages causes infinite requeues and suggested using 'Nack(false)' to prevent poison message loops.

Comment thread apps/backend/libs/amqp/src/amqp.service.ts Outdated
Comment thread apps/backend/libs/amqp/src/amqp.service.ts Outdated
@Choi-Jung-Hyeon Choi-Jung-Hyeon linked an issue May 22, 2026 that may be closed by this pull request
27 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🪰 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 26-1 백엔드 버그픽스

2 participants