moeru-ai/airi · warning

Failed to handle spark:emit event:

Error message

Failed to handle spark:emit event:

What it means

Twin of the spark:notify guard: the orchestrator's 'spark:emit' subscription catches any rejection from handleSparkEmit and logs it. spark:emit is the outbound path (a mod/character emitting an action or message), so a failure here means the emitted event could not be processed — payload validation, store mutation, or downstream dispatch threw.

Source

Thrown at packages/stage-ui/src/stores/character/orchestrator/store.ts:288

    eventUnsubscribes.push(
      modsServerChannelStore.onEvent('spark:notify', async (event) => {
        try {
          await handleIncomingSparkNotify(event)
        }
        catch (error) {
          console.warn('Failed to handle spark:notify event:', error)
        }
      }),
    )

    eventUnsubscribes.push(
      modsServerChannelStore.onEvent('spark:emit', async (event) => {
        try {
          await handleSparkEmit(event)
        }
        catch (error) {
          console.warn('Failed to handle spark:emit event:', error)
        }
      }),
    )

    startTicker()
  }

  function dispose() {
    stopTicker()

    for (const unsubscribe of eventUnsubscribes) {
      unsubscribe()
    }

    eventUnsubscribes.length = 0
    initialized = false
  }

View on GitHub (pinned to 677329427f)

Solutions

  1. Read the logged error and fix the mod's emit call or payload shape.
  2. Align mod SDK and orchestrator versions so emit schemas match.
  3. Avoid emitting during teardown — check store liveness in the mod or unsubscribe mods before dispose.
  4. Add payload validation (Valibot schema) at the emit boundary so invalid events are rejected with a clear message.
Defensive patterns

Strategy: try-catch

Validate before calling

const sparkEmitSchema = /* Valibot schema for emit payloads */
function isSparkEmitPayload(event: unknown): boolean {
  return sparkEmitSchema.safeParse(event).success
}

Try / catch

modsServerChannelStore.onEvent('spark:emit', async (event) => {
  try {
    await handleSparkEmit(event)
  }
  catch (error) {
    console.warn('Failed to handle spark:emit event:', error)
    // keep listener alive; report to mod author tooling
  }
})

Prevention

When it happens

Trigger: A mod calls spark emit with a payload the orchestrator cannot apply: unknown event type, missing fields, a store action throwing on the emitted data, or dispatch to a sink (UI/server channel) failing synchronously.

Common situations: Mod authored against a newer/older emit schema; emitting while the target session/store is disposed; character state missing a reference the emit tries to touch; duplicate event ids hitting a uniqueness assertion.

Related errors


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