Skip to content

[fix] createApplicationSSE import 분리#1071

Merged
seongwon030 merged 1 commit intodevelop-fefrom
fix/SSE-import
Jan 19, 2026
Merged

[fix] createApplicationSSE import 분리#1071
seongwon030 merged 1 commit intodevelop-fefrom
fix/SSE-import

Conversation

@seongwon030
Copy link
Member

@seongwon030 seongwon030 commented Jan 19, 2026

#️⃣연관된 이슈

ex) #이슈번호, #이슈번호

📝작업 내용

  • eventSource import를 피하기 위해 SSE 함수 다른 파일로 분리
  • RN에서 eventSource 호환불가능으로 에러 가능성

중점적으로 리뷰받고 싶은 부분(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

논의하고 싶은 부분(선택)

논의하고 싶은 부분이 있다면 작성해주세요.

🫡 참고사항

@seongwon030 seongwon030 self-assigned this Jan 19, 2026
@seongwon030 seongwon030 added the 🐞 Bug Something isn't working label Jan 19, 2026
@vercel
Copy link

vercel bot commented Jan 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
moadong Ready Ready Preview, Comment Jan 19, 2026 8:26am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Invalid regex pattern for base branch. Received: "**" at "reviews.auto_review.base_branches[0]"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Walkthrough

SSE 기반의 createApplicantSSE API 함수를 frontend/src/apis/club.ts에서 새로운 전용 모듈 frontend/src/apis/clubSSE.ts로 재배치하고, 해당 import를 AdminClubContext.tsx에서 업데이트하는 코드 재구성입니다.

Changes

Cohort / File(s) 요약
SSE 함수 분리
frontend/src/apis/clubSSE.ts
EventSource를 통한 실시간 지원자 상태 업데이트 기능을 새로운 전용 모듈로 추가. Authorization 헤더 주입, 토큰 관리, applicant-status-changed 이벤트 핸들링 포함
기존 모듈 정리
frontend/src/apis/club.ts
createApplicantSSE 함수 및 관련 import 제거 (53줄)
import 경로 업데이트
frontend/src/context/AdminClubContext.tsx
createApplicantSSE import 경로를 @/apis/club에서 @/apis/clubSSE로 변경

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

📬 API

Suggested reviewers

  • lepitaaar
  • Zepelown
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 createApplicantSSE를 새로운 clubSSE 모듈로 분리하는 주요 변경사항을 명확하게 설명하고 있습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/src/context/AdminClubContext.tsx (1)

41-41: EventSource 타입 불일치 수정 필요

AdminClubContext.tsx 41번 줄의 eventSourceRef는 브라우저의 전역 EventSource 타입으로 선언되어 있지만, createApplicantSSEeventsource 라이브러리에서 임포트한 EventSource 타입을 반환합니다.

eventSourceRef.current = createApplicantSSE(...)에서 eventsource 라이브러리의 EventSource를 브라우저의 EventSource 타입 ref에 할당하고 있어 타입 불일치가 발생합니다.

AdminClubContext.tsx에서 import { EventSource } from 'eventsource';를 추가하고 ref 선언 타입을 일치시켜야 합니다.

🧹 Nitpick comments (2)
frontend/src/apis/clubSSE.ts (2)

12-53: 사용되지 않는 변수와 불필요한 connect 함수 래핑

eventSource 변수(라인 12)와 connect 함수가 선언되어 있지만, 현재 구조에서는 connect()가 한 번만 호출되고 즉시 반환됩니다. 재연결 로직이 이 함수 내부에 없다면 코드를 단순화할 수 있습니다.

♻️ 단순화된 코드 제안
 export const createApplicantSSE = (
   applicationFormId: string,
   eventHandlers: ApplicantSSECallbacks,
 ): EventSource | null => {
-  let eventSource: EventSource | null = null;
-
-  const connect = (): EventSource | null => {
-    const accessToken = localStorage.getItem('accessToken');
-    if (!accessToken) return null;
+  const accessToken = localStorage.getItem('accessToken');
+  if (!accessToken) return null;

-    const source = new EventSource(
-      `${API_BASE_URL}/api/club/applicant/${applicationFormId}/sse`,
-      {
-        fetch: (input, init) =>
-          fetch(input, {
-            ...init,
-            headers: {
-              ...init?.headers,
-              Authorization: `Bearer ${accessToken}`,
-            },
-            credentials: 'include',
-          }),
-      },
-    );
+  const source = new EventSource(
+    `${API_BASE_URL}/api/club/applicant/${applicationFormId}/sse`,
+    {
+      fetch: (input, init) =>
+        fetch(input, {
+          ...init,
+          headers: {
+            ...init?.headers,
+            Authorization: `Bearer ${accessToken}`,
+          },
+          credentials: 'include',
+        }),
+    },
+  );

-    source.addEventListener('applicant-status-changed', (e) => {
-      try {
-        const eventData: ApplicantStatusEvent = JSON.parse(e.data);
-        eventHandlers.onStatusChange(eventData);
-      } catch (parseError) {
-        console.error('SSE PARSING ERROR:', parseError);
-      }
-    });
+  source.addEventListener('applicant-status-changed', (e) => {
+    try {
+      const eventData: ApplicantStatusEvent = JSON.parse(e.data);
+      eventHandlers.onStatusChange(eventData);
+    } catch (parseError) {
+      console.error('SSE PARSING ERROR:', parseError);
+    }
+  });

-    source.onerror = (error) => {
-      source.close();
-      eventHandlers.onError(
-        new Error(error?.message || 'SSE connection error'),
-      );
-    };
+  source.onerror = (error) => {
+    source.close();
+    eventHandlers.onError(
+      new Error(error?.message || 'SSE connection error'),
+    );
+  };

-    return source;
-  };
-
-  eventSource = connect();
-  return eventSource;
+  return source;
 };

37-39: 파싱 에러 시 사용자에게 피드백 누락

JSON 파싱 에러가 발생해도 console.error만 호출하고 eventHandlers.onError를 호출하지 않습니다. 이로 인해 잘못된 데이터 수신 시 호출자가 인지하지 못할 수 있습니다.

♻️ 에러 핸들러 호출 추가
     source.addEventListener('applicant-status-changed', (e) => {
       try {
         const eventData: ApplicantStatusEvent = JSON.parse(e.data);
         eventHandlers.onStatusChange(eventData);
       } catch (parseError) {
         console.error('SSE PARSING ERROR:', parseError);
+        eventHandlers.onError(new Error('Failed to parse SSE event data'));
       }
     });

Copy link
Collaborator

@suhyun113 suhyun113 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨어여~

@seongwon030 seongwon030 merged commit 93f2831 into develop-fe Jan 19, 2026
3 checks passed
@seongwon030 seongwon030 deleted the fix/SSE-import branch January 19, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 Bug Something isn't working 💻 FE Frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants