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

@@ -1,5 +1,5 @@
// Typed engine calls used by Express Mode. Ported from prototype/engine.js.
import { EngineError, opKey, request, sleep } from './client'
import { EngineError, limiter, opKey, request, sleep } from './client'
import { t } from '../i18n'
// ── Documents (Brain) ──
@@ -76,7 +76,10 @@ export interface KnowledgeDetail {
error: string | null
}
export const knowledgeDetail = (id: number) => request<KnowledgeDetail>(`/upload/${id}/knowledge`)
// The Upload page asks once per document waiting on an answer; two at a time keeps a long list
// from tripping the proxy's rate limit.
const twoAtATime = limiter(2)
export const knowledgeDetail = (id: number) => twoAtATime(() => request<KnowledgeDetail>(`/upload/${id}/knowledge`))
// Agree to the quoted price, build after a top-up, or retry a failed build. Spends workspace credits (402 when short).
// Reads a failed document's stored file again, for free. A knowledge base it already has is kept.