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
- Read the logged error and fix the mod's emit call or payload shape.
- Align mod SDK and orchestrator versions so emit schemas match.
- Avoid emitting during teardown — check store liveness in the mod or unsubscribe mods before dispose.
- 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
- Version emit schemas and reject mismatched versions at the boundary.
- Check store liveness before mutating on emit, especially during dispose.
- Write Vitest coverage for emit payload edge cases in the orchestrator.
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
- Failed to handle spark:notify event:
- Dropped spark:notify after max attempts:
- [context-bridge] spark:notify handling failed; using fallbac
- [llm-streaming-control] signal handler failed
- [llm-streaming-control] handler failed
AI-assisted analysis of moeru-ai/airi@677329427f (2026-08-18).
Data as JSON: /api/errors/531c8ea3989c047d.
Report an issue: GitHub.