app-builder: conversation is permanently wedged after a server restart (unknown_session not recovered)

Aperta
#88 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, react, typescript
Ambito
backend, frontend

Direzione di ricerca

Start in sdk/app-builder/src/app/app-builder.tsx at the restore flow around lines 345–390 and the manual Retry flow around lines 861 and 890; read how missing_api_key is handled and how requestSession accepts a session ID. Check the server response in src/app/api/sessions/route.ts to confirm the unknown_session code. Done when both flows clear the stale session and request a fresh one, and retry no longer repeats the 404 after a server restart.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What

In app-builder, after the server process recycles (e.g. you restart pnpm dev) and you reload the page, the restored conversation gets permanently stuck on a session error. The on-screen "Retry" doesn't help; only "Change API key" or creating a new conversation recovers.

Why

Sessions are an in-process Map on the server (sdk/app-builder/src/lib/app-builder/server.ts:159) — only the API key is persisted client-side, not sessions. On reload, the client restores conversation.session.id from localStorage and re-sends that stale id:

  • restore sends restoredSessionId = activeConversation.session?.id (app-builder.tsx:345-349), and the manual Retry does the same (:861, :890).
  • the server no longer has that session → restoreSession throws UnknownAppBuilderSessionError (server.ts:241-244), which the route maps to HTTP 404 with code: "unknown_session" (src/app/api/sessions/route.ts:71-79).

The client's restore catch (app-builder.tsx:365-390) only special-cases isMissingApiKeyError (which matches code === "missing_api_key" only, :3863-3865). An unknown_session error falls through to the generic branch, which sets sessionError but never clears the dead conversation.session. Retry reuses the same stale id → the same 404. The conversation is wedged.

This is exactly the restart-the-demo path, so it hits in normal local use.

Suggested fix

Treat code === "unknown_session" as a cache miss, next to the existing missing_api_key handling: drop conversation.session and mint a fresh one by calling requestSession(validSavedApiKey, undefined, …) (no stale sessionId). Same for the manual Retry path (retrySavedApiKey).

I filed this as an issue rather than a PR because the fix sits in the restore/retry React flow and I couldn't run app-builder to verify the retry doesn't loop; happy to send a PR if you'd like. Found on main @ e1c3f64.

Lingua principale
TypeScript
Stelle
4.2k
Fork
503
Merge medio
3g 23h
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cursor/cookbook

Tutte le issue di cursor/cookbook

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.