Repository navigation
Develop #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Develop #39
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bf2f380
fix :: SSE 구독 시 초기 데이터 미전송 문제 수정
cfcromn 6c1d95e
fix :: 신규 구독 시 기존 클라이언트에 불필요한 브로드캐스트 제거
cfcromn 220e6c7
Merge pull request #37 from DarkMode-Lap/fix/sse-initial-send
cfcromn c4293c4
update :: SSE 연결 관리 로직 개선
cfcromn eb6b2c4
fix :: SSE 전송 실패 시 emitter complete() 명시적 호출로 자원 누수 방지
cfcromn fef1891
fix :: SSE heartbeat·send 예외 범위 확대 및 동시 연결 검사 동기화
cfcromn b0cea1f
Merge pull request #38 from DarkMode-Lap/feat/sse-connection-management
cfcromn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/team/darkmoderap/aikon/domain/avatar/event/AvatarSseSubscribedEvent.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package team.darkmoderap.aikon.domain.avatar.event | ||
|
|
||
| import org.springframework.web.servlet.mvc.method.annotation.SseEmitter | ||
|
|
||
| class AvatarSseSubscribedEvent( | ||
| val emitter: SseEmitter, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
onAvatarSseSubscribed, iffindAvatarChanges()throws an exception (e.g., due to a database connection timeout or query failure), the exception will propagate out of the@Asyncmethod. Becausesendis never called, thecleanupmethod is never invoked, leaving theSseEmitterin theemitterslist indefinitely (until it eventually times out, which is set to 30 minutes). This can leak connection slots and quickly exhaustmaxConnectionsunder database error conditions.We should wrap the execution in a
runCatchingblock and ensurecleanupis called withcomplete = trueif an exception occurs.@Async @EventListener @Transactional(readOnly = true) fun onAvatarSseSubscribed(event: AvatarSseSubscribedEvent) { runCatching { findAvatarChanges() } .onSuccess { send(event.emitter, it) } .onFailure { e -> logger.error("Failed to send initial avatar changes", e) cleanup(event.emitter, "initial send failed", complete = true) } }