moeru-ai/airi · warning

[KokoroAdapter] Restarting in ${delay}ms (attempt ${restartA

Error message

[KokoroAdapter] Restarting in ${delay}ms (attempt ${restartAttempts}/${MAX_RESTARTS})

What it means

The Kokoro TTS adapter supervises a Web Worker; when the worker errors/terminates, scheduleRestart() applies linear backoff (RESTART_DELAY_MS × attempt) up to MAX_RESTARTS, logging each attempt with this warn. After the cap it logs an error and flips state to 'terminated' so getKokoroAdapter() can replace the dead singleton on next access. The warn itself is healthy self-healing, not a defect.

Source

Thrown at packages/stage-ui/src/libs/inference/adapters/kokoro.ts:288

      worker = null
    }
  }

  function scheduleRestart(): void {
    if (restartAttempts >= MAX_RESTARTS) {
      console.error(
        `[KokoroAdapter] Max restart attempts (${MAX_RESTARTS}) reached.`,
      )
      // NOTICE: Transition to 'terminated' so getKokoroAdapter() can detect
      // the dead singleton and create a fresh adapter on next access.
      state = 'terminated'
      return
    }

    restartAttempts++
    const delay = RESTART_DELAY_MS * restartAttempts

    console.warn(
      `[KokoroAdapter] Restarting in ${delay}ms `
      + `(attempt ${restartAttempts}/${MAX_RESTARTS})`,
    )

    setTimeout(() => {
      ensureStarted().catch((err) => {
        console.error('[KokoroAdapter] Restart failed:', err)
      })
    }, delay)
  }

  function onSuccess(): void {
    restartAttempts = 0
  }

  async function ensureStarted(): Promise<void> {
    await lifecycleMutex.runExclusive(async () => {
      if (!worker) {

View on GitHub (pinned to 677329427f)

Solutions

  1. Reproduce with the worker console open to capture the underlying error (this warn is only the retry signal).
  2. Lower the model quantization / dtype so the worker uses less memory.
  3. Update transformers.js / onnxruntime-web to versions compatible with your browser.
  4. If it reached 'terminated', call getKokoroAdapter() again — it creates a fresh adapter with a fresh restart budget.
Defensive patterns

Strategy: retry

Prevention

When it happens

Trigger: Worker crash from an uncaught exception (WASM abort, OOM in transformers.js), browser killing the worker under memory pressure, or repeated failed model loads during ensureStarted().

Common situations: Low-memory devices loading large Kokoro quantizations; transformers.js/runtime version incompatibility; onnxruntime-web WASM SIMD unsupported so the worker aborts.

Related errors


AI-assisted analysis of moeru-ai/airi@677329427f (2026-08-18). Data as JSON: /api/errors/ddfd28c915277bdc. Report an issue: GitHub.