groups 조회 시, RLS 내부 조건에서 group_members 테이블을 서브쿼리(**subquery)**로 참조했음.group_members 정책에서도 “같은 그룹 멤버만 볼 수 있음” 이라는 조건에서 groups 를 역으로 참조함..결과적으로 두 테이블이 서로 RLS 평가 시 상대 테이블을 요구하게 되어
Supabase가 내부적으로 정책 평가 루프 → “쿼리 응답 지연 또는 500/403 반복” → 프론트에서 자동 재시도 → 무한 재귀 fetch 루프 발생
-- groups RLS
create policy "view approved or member groups"
on groups for select
to authenticated
using (
approved = true
or exists (
select 1
from group_members gm
where gm.group_id = groups.group_id
and gm.user_id = auth.uid()
)
);
-- group_members RLS
create policy "view same group members"
on group_members for select
to authenticated
using (
exists (
select 1
from groups g
where g.group_id = group_members.group_id
and (g.approved = true or g.created_by = auth.uid())
)
);
groups)에서 참조를 제거하고 역할을 분리해 단방향 검증 구조로 수정.-- 그룹
create policy "view approved groups"
on groups for select
to authenticated
using (approved = true or created_by = auth.uid());
-- 멤버
create policy "view members of same group"
on group_members for select
to authenticated
using (
exists (
select 1
from group_members gm2
where gm2.group_id = group_members.group_id
and gm2.user_id = auth.uid()
)
);