Skip to content

fix(participant): zustand v5 객체 selector 무한 루프로 참가 화면 크래시 수정 - #37

Merged
lsmin3388 merged 1 commit into
mainfrom
fix/participant-store-selector
Jun 8, 2026
Merged

fix(participant): zustand v5 객체 selector 무한 루프로 참가 화면 크래시 수정#37
lsmin3388 merged 1 commit into
mainfrom
fix/participant-store-selector

Conversation

@lsmin3388

Copy link
Copy Markdown
Contributor

증상

참가자가 PIN 입장 직후 "연결이 잠깐 끊겼어요"(play/error.tsx)가 뜸. join 은 성공해 인원만 1씩 누적되고, 재시도할수록 더 늘어남.

원인

참가 화면들이 useParticipantStore((s) => ({ ... }))매 렌더 새 객체를 반환. zustand v5 는 useSyncExternalStore 기반이라 이 패턴은 매 렌더 스냅샷이 달라져 "Maximum update depth exceeded" 를 던짐 → React 가 에러 바운더리로 폴백.

수정

객체 리터럴 selector → 개별 원시값 selector 로 분리(s => s.participantId 등).

  • 대상: PlayerWaiting/Question/Result/Leaderboard, useSubmitAnswer
  • 잔여 객체 selector 0 (grep 확인), pnpm tsc --noEmit

- useParticipantStore 의 객체 리터럴 selector(매 렌더 새 객체) → 개별 selector 로 분리
- zustand v5(useSyncExternalStore 기반)에서 이 패턴은 "Maximum update depth exceeded"를 던져 참가 화면이 error.tsx("연결이 잠깐 끊겼어요")로 크래시했음. join 은 성공해 인원만 누적됨
- 대상: PlayerWaitingClient, PlayerQuestionClient, PlayerResultClient, PlayerLeaderboardClient, useSubmitAnswer
@lsmin3388
lsmin3388 merged commit 707b90a into main Jun 8, 2026
@lsmin3388
lsmin3388 deleted the fix/participant-store-selector branch June 8, 2026 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant