fix: 크루 전환 시 사용자 메시지 유실 방지 (사전 저장 분리) - #247
Open
byoungholee0821 wants to merge 1 commit into
Open
Conversation
- thread: appendUserMsg, completePendingTurn, failPendingTurn 3단계 영속화 함수 구현 - chat route: POST 핸들러를 지시 사전 저장 -> 답변 생성 -> 완료/실패 3단계 구조로 변경 - page: pending 메시지 opacity 조절 및 ArgoSpinner + 답변 대기 중 표시 - i18n: chat.pending ko/en 번역 키 추가 - docs: 크루 전환 유실 이슈 분석 및 구현 결과 문서 추가 (006, 007)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 문제점 및 배경
질문을 전송한 후 크루 답변이 생성되는 동안(수초~수분 소요), 사용자가 다른 크루로 전환하거나 페이지를 새로고침하면 작성했던 질문 메시지가 화면과 디스크에서 완전히 유실되는 현상이 발생했습니다.
근본 원인
appendTurn은 사용자 지시문과 크루 답변을 한 번에 쌍(Pair)으로 묶어서 디스크에 저장했습니다.null로 초기화되어 질문이 영구 소실되었습니다.🛠️ 해결 방안 (3단계 영속화 구조)
1단계 (
appendUserMsg- 지시 사전 저장)mid)와pending: true상태로 사용자 메시지를 먼저 디스크에 원자적(Atomic)으로 기록합니다.pending: true지시문을 복원합니다.2단계-성공 (
completePendingTurn- 답변 완료)mid를 찾아pending상태를 해제하고 크루 답변을 추가합니다.3단계-실패 (
failPendingTurn- 에러/중단)pending메시지에failed사유를 기록하여 사용자가 돌아왔을 때 재전송(Resend) 버튼으로 즉시 재시도할 수 있도록 지원합니다.🔍 핵심 변경 파일
src/thread.mjs:appendUserMsg,completePendingTurn,failPendingTurn3단계 영속화 함수 추가app/api/companies/[ws]/chat/route.js: POST 핸들러 3단계 구조로 변경app/c/[ws]/crew/[slug]/page.jsx:pending메시지 대기 UI 표시 (ArgoSpinner+t('chat.pending')) 및 실패 시 재전송 UIapp/i18n.jsx:chat.pendingko/en 다국어 번역 키 추가✅ 검증
node --check정합성 검사 통과withLock)으로 동시성 디스크 쓰기 안전 보장