Skip to content

fix: clear stale conversation_id on 404 to prevent infinite retry loop#35003

Open
samrusani wants to merge 1 commit intolanggenius:mainfrom
samrusani:fix/stale-conversation-id-infinite-404-loop
Open

fix: clear stale conversation_id on 404 to prevent infinite retry loop#35003
samrusani wants to merge 1 commit intolanggenius:mainfrom
samrusani:fix/stale-conversation-id-infinite-404-loop

Conversation

@samrusani
Copy link
Copy Markdown
Contributor

@samrusani samrusani commented Apr 12, 2026

Summary

When a conversation is deleted server-side, the Web App chatbot entered an infinite 404 error loop because the stale conversation_id persisted in localStorage and TanStack Query kept retrying.

  • Added a retry function to useShareChatList that skips retries on 404 responses (unrecoverable errors)
  • Added a useEffect in both chat-with-history/hooks.tsx and embedded-chatbot/hooks.tsx to detect 404 errors and clear the stale conversation_id from localStorage, resetting to a new conversation state

Fixes #34731

Screenshots

N/A — logic-only change, no visual changes.

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

From Claude Code

…infinite retry loop

When a conversation is deleted server-side, the frontend kept retrying
with the stale conversation_id from localStorage, creating an infinite
404 error loop. This fix:

1. Disables TanStack Query retries on 404 in useShareChatList
2. Adds a useEffect in both chat-with-history and embedded-chatbot hooks
   to clear the stale conversation_id from localStorage when a 404 is
   detected, resetting the user to a new conversation state

Closes langgenius#34731

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@samrusani samrusani requested a review from iamjoel as a code owner April 12, 2026 15:52
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 12, 2026
@samrusani samrusani requested a review from zxhlyh as a code owner April 12, 2026 15:52
@github-actions github-actions bot added the web This relates to changes on the web. label Apr 12, 2026
@dosubot dosubot bot added the javascript Pull requests that update javascript code label Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update javascript code size:S This PR changes 10-29 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stale conversation_id in localStorage causes infinite 404 "Conversation Not Exists" loop in Web App chatbot

1 participant