Keep a page error or a busy engine from blanking the app

A user on Upload got a white page while the engine's proxy answered
many requests with nginx's rate-limit 503.

- Pages render inside an error boundary, so a crash shows a message
  with Try again and Reload instead of unmounting the whole app.
- A 503 or 429 without the engine's JSON reads "The engine is busy",
  and queries wait 5s, then 10s, before asking again instead of 1s.
- Upload asks for knowledge details two at a time and reuses them
  until the document's knowledge status changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Iqbal
2026-10-29 18:38:18 +07:00
parent a47fe0f845
commit dfb3275afe
8 changed files with 97 additions and 5 deletions

View File

@@ -296,7 +296,8 @@ function Progress({ doc }: { doc: Source }) {
// Each stop the engine can make before building, with the one answer it needs.
function KnowledgeAction({ doc }: { doc: Source }) {
const queryClient = useQueryClient()
const detail = useQuery({ queryKey: ['knowledge', doc.docId, doc.knowledge], queryFn: () => knowledgeDetail(doc.docId) })
// Keyed by the knowledge status, so it is read again when that changes and reused otherwise.
const detail = useQuery({ queryKey: ['knowledge', doc.docId, doc.knowledge], queryFn: () => knowledgeDetail(doc.docId), staleTime: 5 * 60_000 })
const refresh = () => queryClient.invalidateQueries({ queryKey: ['documents'] })
const build = useMutation({ mutationFn: () => buildKnowledge(doc.docId), onSuccess: refresh })
const version = useMutation({ mutationFn: (link: boolean) => answerVersion(doc.docId, link), onSuccess: refresh })