Skip to content

Fix SpeechRecognizer error handling for "ERROR_SERVER_DISCONNECTED" in Android#125

Open
itsmorty wants to merge 2 commits into
capacitor-community:masterfrom
itsmorty:bugfix/android-error-server-disconnected
Open

Fix SpeechRecognizer error handling for "ERROR_SERVER_DISCONNECTED" in Android#125
itsmorty wants to merge 2 commits into
capacitor-community:masterfrom
itsmorty:bugfix/android-error-server-disconnected

Conversation

@itsmorty
Copy link
Copy Markdown

@itsmorty itsmorty commented Dec 7, 2025

Fixes #124

Added methods to manage SpeechRecognizer lifecycle.

Added new error key ERROR_SERVER_DISCONNECTED to getErrorText cases.

Normal flow: Reuse the same SpeechRecognizer instance (just cancel any pending work and set a new listener)

After error: The onError handler destroys and nullifies the recognizer synchronously, so the next start() will create a fresh one

Pull request checklist

Please check if your PR fulfills the following requirements:

  • The changes have been tested successfully.

Note: I used AI agents (1. GPT-5.1-Codex 2. Gemini 3 Pro, 3. Claude Opus 4.5) with caution to debug/review this issue but still needs a precise review of you maintainer guys :D
@priyankpat @mrbatista

Added methods to manage SpeechRecognizer lifecycle.

Added new error key `ERROR_SERVER_DISCONNECTED` to `getErrorText` cases.

Normal flow: Reuse the same SpeechRecognizer instance (just cancel any pending work and set a new listener)

After error: The onError handler destroys and nullifies the recognizer synchronously, so the next start() will create a fresh one
@itsmorty itsmorty changed the title Enhance SpeechRecognizer management and error handling Fix SpeechRecognizer error handling for "ERROR_SERVER_DISCONNECTED" in Android Dec 7, 2025
Removed unused imports for Handler and Looper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Android SpeechRecognizer ERROR_SERVER_DISCONNECTED (11) — recorder fails to start on every other attempt (API 35)

1 participant