Skip to content

Speech profile onboarding breaks on pod rollout with no way to resume #5869

Closed as not planned

Description

@beastoin

When a backend-listen rolling update happens while a user is doing speech profile onboarding, the WebSocket connection is terminated and the user sees "Connection Lost." They cannot resume — they must restart the entire onboarding flow from scratch, losing all progress and recorded audio.

Current Behavior

  • User starts speech profile onboarding (6 questions, ~2-3 min flow)
  • A kubectl rollout restart or Helm upgrade cycles backend-listen pods (19-22 pods killed + recreated)
  • The user's WebSocket (/v4/listen?onboarding=enabled) is terminated when their pod is killed
  • App receives socket close → shows "Connection Lost" dialog with only "Try Again" (which pops the page)
  • All recorded audio, transcript segments, and answered questions are lost
  • User must redo the entire onboarding from question 1

Expected Behavior

User should be able to resume onboarding from where they left off after a connection drop.

Why This Is Bad

  • Onboarding is the first experience for new users — a "Connection Lost" error with no recovery creates a terrible first impression
  • The user answered 5/6 questions (83% complete) and lost all progress
  • Rolling updates happen regularly (every deploy triggers kubectl rollout restart on backend-listen)
  • Users on flaky mobile connections (cellular, weak WiFi) hit this even without deploys — cancelOnError: true in pure_socket.dart:126 kills the connection on any single transient error

Root Cause

  1. No server-side onboarding state persistence — OnboardingHandler (backend/utils/onboarding.py) stores all state in memory (answered questions, transcript, current index). When the pod dies, everything is lost.
  2. No client-side reconnection for speech profile — SpeechProfileProvider (app/lib/providers/speech_profile_provider.dart) has no reconnect logic. When onClosed() fires during recording, it shows the error dialog and the user can only go back.
  3. No connection draining during rollout — pods are killed immediately without waiting for active WebSocket sessions to complete.
  4. cancelOnError: true in pure_socket.dart:126 — a single transient network error kills the WebSocket permanently with no retry.

Confirmed Trigger

  • Mar 21 rolling update: 19 pods killed + 15 created between 00:00-01:00 UTC
  • User screenshot shows "Connection Lost" at 83% (question 5/6: "What do you have planned for today?")
  • No errors in backend logs — the pod was simply killed during the rollout

Affected Areas

File Description
backend/utils/onboarding.py In-memory only state, no persistence
app/lib/providers/speech_profile_provider.dart No reconnect/resume logic
app/lib/pages/onboarding/speech_profile_widget.dart Error dialog only offers "Try Again" (restart)
app/lib/services/sockets/pure_socket.dart:126 cancelOnError: true kills connection on transient errors

Possible Solutions

  1. Short-term: client-side reconnect + resume — on socket close during onboarding, auto-reconnect the WebSocket and resend the current question index so the backend picks up from the right question. Answered questions and audio are already stored client-side in the provider.
  2. Short-term: graceful pod drain — add terminationGracePeriodSeconds and preStop hook to backend-listen pods to allow active WebSocket sessions to complete before killing.
  3. Medium-term: server-side onboarding state in Redis — persist question progress and answers in Redis keyed by UID so a new pod can resume from where the old one left off.
  4. Quick fix: cancelOnError: false — change pure_socket.dart:126 so transient network errors don't immediately kill the connection.

by AI for @beastoin

Activity

  1. added
    p1
    on Mar 21, 2026
  2. beastoin commented on Mar 21, 2026

    @beastoin
    CollaboratorAuthor
  3. added
    p2
    and removed
    p1
    on Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions