Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
체크 리스트
작업 내역
@nestjs/event-emitter
는 내부적으로 event emitter2를 사용하고 있다. 기존에도 정상적으로 동작하긴 했으나 사용법이 적절하지 못해 수정했다.기존에는 아래와 같이 비동기함수인 event listenr를 단순히 emit해 우회적으로 동작시켰다.
web13-moyeomoyeo/backend/src/app/group-article/group-article.service.ts
Lines 95 to 98 in 399ce79
web13-moyeomoyeo/backend/src/app/notification/notification.listener.ts
Lines 27 to 30 in 399ce79
async옵션을 통해 setImmediate를 사용해 비동기적으로 호출될 수 있도록 아래와 같이 변경했다.
web13-moyeomoyeo/backend/src/app/group-article/group-article.service.ts
Lines 95 to 98 in 6f41f44
web13-moyeomoyeo/backend/src/app/notification/notification.listener.ts
Lines 27 to 30 in 6f41f44
문제 상황과 해결
{ nextTick: true }
옵션을 주어 next tick에 바로 실행되도록 할수도 있다. setImmediate는 이벤트 루프에 check phase에 실행되고 nextTick은 nextTickQueue에 담겨 다음 페이즈로 넘어가기전에 실행된다.두 옵션 모두 비동기적으로 동작하게 할 수 있는데 어떤 옵션을 주는게 좋을까?
비고