Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/ToastItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function ToastItem({ toastObj, index }: { toastObj: ToastObj; ind

const animation = `toast-blink ${toastObj.time}s ease-in-out forwards`;
const toastStyle = twMerge(
'fixed bottom-5 left-1/2 z-40 flex h-[40px] max-w-150 min-w-[300px] w-[80%] -translate-1/2 items-center justify-center rounded-lg caption-sb shadow-[0_1px_6px_rgba(200,200,200,0.2)]',
'fixed bottom-5 left-1/2 z-50 flex h-[40px] max-w-150 min-w-[300px] w-[80%] -translate-1/2 items-center justify-center rounded-lg caption-sb shadow-[0_1px_6px_rgba(200,200,200,0.2)]',
TOAST_POSITION[toastObj.position],
TOAST_DESIGN[toastObj.toastType].style,
);
Expand Down
22 changes: 10 additions & 12 deletions src/hooks/useServerSentEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const useServerSentEvents = () => {
let reconnect: number | undefined;

const navigate = useNavigate();
const recallCountRef = useRef(1);
// const recallCountRef = useRef(1);

const accessToken = useAuthStore((state) => state.accessToken);
const setAccessToken = useAuthStore((state) => state.setAccessToken);
Expand Down Expand Up @@ -77,22 +77,20 @@ export const useServerSentEvents = () => {
handleOnMessage(event.data);
};

sourceRef.current.onerror = () => {
// 에러 발생시 해당 에러가 45초를 넘어서 발생한 에러인지, 401에러인지 판단할 수 있는게 없어서 그냥 에러 발생하면 reissue 넣는걸로 때움
callReissue();
closeSSE();
recallCountRef.current += 1;
console.log('SSE연결 에러 발생');

// 재연결 로직 추가 가능
if (recallCountRef.current < 5) {
sourceRef.current.onerror = (event) => {
console.log(event);
const errorEvent = event as unknown as { status?: number };
if (errorEvent.status === 401) {
callReissue();
closeSSE();
reconnect = setTimeout(connectSSE, 5000);
} else {
console.log('5회 이상 에러발생으로 구독기능 제거');
closeSSE();
reconnect = setTimeout(connectSSE, 5000);
}
};
} catch (error) {
console.error(error);
console.log('catch문에서 에러 발생', error);
}
};

Expand Down