File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export const useServerSentEvents = () => {
1616 let reconnect : number | undefined ;
1717
1818 const navigate = useNavigate ( ) ;
19+ const recallCountRef = useRef ( 1 ) ;
1920
2021 const accessToken = useAuthStore ( ( state ) => state . accessToken ) ;
2122 const setAccessToken = useAuthStore ( ( state ) => state . setAccessToken ) ;
@@ -80,8 +81,15 @@ export const useServerSentEvents = () => {
8081 // 에러 발생시 해당 에러가 45초를 넘어서 발생한 에러인지, 401에러인지 판단할 수 있는게 없어서 그냥 에러 발생하면 reissue 넣는걸로 때움
8182 callReissue ( ) ;
8283 closeSSE ( ) ;
84+ recallCountRef . current += 1 ;
85+ console . log ( recallCountRef . current ) ;
86+
8387 // 재연결 로직 추가 가능
84- reconnect = setTimeout ( connectSSE , 5000 ) ;
88+ if ( recallCountRef . current < 5 ) {
89+ reconnect = setTimeout ( connectSSE , 5000 ) ;
90+ } else {
91+ console . log ( '5회 이상 에러발생으로 구독기능 제거' ) ;
92+ }
8593 } ;
8694 } catch ( error ) {
8795 console . log ( '에러' , error ) ;
You can’t perform that action at this time.
0 commit comments