moeru-ai/airi · warning
Error stopping Web Speech API recognition:
Error message
Error stopping Web Speech API recognition:
What it means
During hearing-session teardown, result.recognition.stop() on the embedded Web Speech API recognition threw — commonly an InvalidStateError because recognition already ended or was aborted. It is caught in a nested try so teardown continues: the idle timer is cleared and streamingSession is cleared regardless. The recognition instance is discarded either way, so the warning is cosmetic.
Source
Thrown at packages/stage-ui/src/stores/modules/hearing.ts:675
asrSpan = undefined
}
// Special handling for Web Speech API
if (session.providerId === 'browser-web-speech-api') {
try {
const reason = new DOMException(abort ? 'Aborted' : 'Stopped', 'AbortError')
if (!session.abortController.signal.aborted) {
session.abortController.abort(reason)
}
// Stop Web Speech API recognition if it exists
const result = session.result as any
if (result?.recognition) {
try {
result.recognition.stop()
}
catch (err) {
console.warn('Error stopping Web Speech API recognition:', err)
}
}
}
catch (err) {
console.error('Error stopping Web Speech API session:', err)
}
if (session.idleTimer)
clearTimeout(session.idleTimer)
streamingSession.value = undefined
if (session.result?.mode === 'stream') {
try {
const text = await session.result.text
return text
}
catch (err) {View on GitHub (pinned to f679616c34)
Solutions
- Ignore it — the recognition instance is discarded anyway and teardown completed
- Guard stop() with the recognition state or drop the reference before calling stop
- Debounce rapid start/stop of the mic to avoid double-stop races
- Abort the session controller first and skip stop() when the signal already aborted
Defensive patterns
Strategy: try-catch
Validate before calling
const result = session.result as any if (!result?.recognition) return // no embedded Web Speech instance to stop
Try / catch
try {
result.recognition.stop()
}
catch (err) {
// InvalidStateError is expected when recognition already ended; teardown continues
console.warn('Error stopping Web Speech API recognition:', err)
} Prevention
- Abort via the AbortController first, then stop() recognition, to avoid double-stop races
- Debounce rapid start/stop toggles of the mic
- Drop the recognition reference as soon as stop() is attempted
When it happens
Trigger: Mic start/stop toggled rapidly so stop() runs after recognition already ended; recognition auto-disconnected (tab switch, permission revoked) before teardown; abort fired first and stop() then throws InvalidStateError.
Common situations: Push-to-talk toggled quickly; browser revoking mic permission mid-session; Safari/Chrome differences in Web Speech lifecycle.
Related errors
- Error stopping recognition instance:
- 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:
AI-assisted analysis of moeru-ai/airi@f679616c34 (2026-08-18).
Data as JSON: /api/errors/60d38261e2a9d171.
Report an issue: GitHub.