moeru-ai/airi · warning
Creating new recognition instance due to error
Error message
Creating new recognition instance due to error
What it means
After an unclassified startRecognition() failure (not 'already started', not permission-related), the provider logs this warning and attempts recovery by discarding the current SpeechRecognition object and building a fresh one via createAndStartNewRecognitionInstance(). It is the mid-path of the restart strategy, not a terminal error — terminal failure is the subsequent 'failed to start after retry' path.
Source
Thrown at packages/stage-ui/src/libs/providers/providers/browser-web-speech-api/provider.ts:402
if (errorMessage.includes('already') || errorMessage.includes('started')) {
// Recognition is already running, this is OK
console.info('Web Speech API recognition already running')
return true
}
if (errorMessage.includes('not-allowed') || errorMessage.includes('permission')) {
// Permission denied - user needs to grant microphone access
const err = new Error('Microphone permission denied. Please grant microphone access and try again.')
console.error('Web Speech API: Microphone permission denied')
fullStreamCtrl?.error(err)
textStreamCtrl?.error(err)
deferredText.reject(err)
deferredText.isRejected = true
return false
}
// For other errors, try creating a new instance
console.warn('Creating new recognition instance due to error')
try {
createAndStartNewRecognitionInstance(recognition)
console.info('Web Speech API recognition restarted successfully with new instance')
return true
}
catch (restartError: any) {
const err = new Error(`Failed to start Web Speech API recognition: ${restartError?.message || String(restartError)}`)
fullStreamCtrl?.error(err)
textStreamCtrl?.error(err)
deferredText.reject(err)
deferredText.isRejected = true
console.error('Web Speech API recognition failed to start after retry:', restartError)
return false
}
}
}
// Add event listeners for debugging before startingView on GitHub (pinned to 677329427f)
Solutions
- Usually self-healing — confirm the next log line says the new instance started successfully.
- If it recurs in a loop, capture the original errorMessage from the preceding 'start failed' log to identify the true cause.
- Add a short cooldown or max-restart counter so a permanently failing engine does not recreate instances in a tight loop.
- Check OS/browser speech service health and microphone device state when retries keep being needed.
Defensive patterns
Strategy: fallback
Try / catch
try {
createAndStartNewRecognitionInstance(recognition)
}
catch (restartError: any) {
const err = new Error(`Failed to start Web Speech API recognition: ${errorMessageFrom(restartError)}`)
// fail the stream once; surface to user rather than looping retries
} Prevention
- Cap instance-recreation attempts to avoid restart loops.
- Log the original start error alongside the recreation attempt for diagnosis.
- Cool down between recreation attempts (the provider already delays restarts).
When it happens
Trigger: recognition.start() threw an error whose message matched neither the 'already started' nor 'not-allowed/permission' branches — e.g. InvalidStateError variants, 'service-not-allowed', or engine-specific exceptions — so the code recreates the instance to reset its lifecycle.
Common situations: Browser engine glitch leaving recognition in a bad internal state; switching input devices mid-session; speech service temporarily unavailable; long sessions where the old object stops accepting start().
Related errors
- Web Speech API is not available in this environment. It requ
- Web Speech API error:
- Web Speech API: Microphone access issue. Please check microp
- Web Speech API failed to restart, creating new instance:
- Web Speech API recognition start failed:
AI-assisted analysis of moeru-ai/airi@677329427f (2026-08-18).
Data as JSON: /api/errors/b373c7a49b4ff807.
Report an issue: GitHub.