Skip to content

Commit 47cb185

Browse files
committed
fix(chat): add delay before deactivating WebSocket connection to ensure message delivery
1 parent 8fd565c commit 47cb185

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/features/chat/hooks/chat-room-ws.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,14 @@ export function useChatRoomSocket(
418418
destination: API_ENDPOINTS.wsLeaveChatRoom,
419419
body: JSON.stringify({ chatRoomId: Number(chatRoomId) }),
420420
});
421-
}
422421

423-
client.deactivate();
422+
// 메시지가 실제로 전송될 시간을 확보하기 위해 약간의 지연 후 연결 해제
423+
setTimeout(() => {
424+
client.deactivate();
425+
}, 200);
426+
} else {
427+
client.deactivate();
428+
}
424429
clientRef.current = null;
425430
};
426431
}, [

0 commit comments

Comments
 (0)