Skip to content

[BUG] First AI enhancement request after ~1.5–2 min idle hangs ~6.5 s, fails with -1005, then succeeds on retry #1016

Closed

Description

@Conte777

Describe the bug

With a cloud AI provider (Groq, openai/gpt-oss-20b / gpt-oss-120b), the first dictation after a short idle period sometimes takes ~7 s to appear instead of the usual 0.3–1 s. The debug log shows the first request hanging for ~6.5 s, failing with NSURLErrorNetworkConnectionLost (-1005), and the automatic retry succeeding in ~0.7 s.

It looks like LLMClient reuses a pooled keep-alive connection that the server or the network path has already closed during idle. The failure is only detected after several seconds, so the retry logic works but the user waits the full detection time.

Log excerpts

[14:52:02.510] LLMClient: Making non-streaming request to https://api.groq.com/openai/v1/chat/completions
[14:52:08.733] [WARN] LLMClient: Retry 1/3 due to -1005
[14:52:08.947] LLMClient: Making non-streaming request to https://api.groq.com/openai/v1/chat/completions
[14:52:09.615] LLMClient: Non-streaming response received (1141 bytes)
[14:56:33.089] LLMClient: Making non-streaming request to https://api.groq.com/openai/v1/chat/completions
[14:56:39.836] [WARN] LLMClient: Retry 1/3 due to -1005
[14:56:40.038] LLMClient: Making non-streaming request to https://api.groq.com/openai/v1/chat/completions
[14:56:40.734] LLMClient: Non-streaming response received (1379 bytes)

In both cases the previous request had completed about 90–120 s earlier. Requests made less than about 60 s apart consistently complete in 0.3–1.0 s (12+ samples).

Reproduction steps

  1. Configure Groq as the AI provider and enable a Dictate prompt.
  2. Dictate once. Processing is fast.
  3. Wait about 1.5–2 minutes.
  4. Dictate again. Sometimes it takes ~7 s, and the log shows Retry 1/3 due to -1005.

Expected behavior

A stale pooled connection is detected or avoided quickly, so the first request after idle is as fast as the others.

Possible directions

  • Retry immediately on -1005 using a fresh connection, or use a shorter timeout for the first attempt.
  • Avoid reusing idle connections older than N seconds for provider requests.
  • Send a lightweight warm-up request (e.g. HEAD/OPTIONS) when recording starts, so the connection is fresh by the time the transcript is ready.

Environment

  • FluidVoice 1.6.9
  • macOS 27 (Darwin 27.0), Apple Silicon (M4)
  • Provider: Groq, OpenAI-compatible endpoint

Activity

  1. github-actions commented on Sep 30, 2026

    @github-actions

    This issue has been marked stale because it has had no activity for 5 days. It will be closed in 2 days if there is no further activity. Add the keep-open or pinned label to prevent automatic closure.

  2. Conte777 commented on Sep 30, 2026

    @Conte777
    Author

    This issue is still relevant. I can share more logs or test a fix if that helps. Could a maintainer add the keep-open label so it isn't auto-closed while it waits for triage? Thanks!

  3. altic-dev commented on Oct 1, 2026

    @altic-dev
    Owner

    if you can help with a small fix just for this - happy to PR and merge. Make sure you review it before submitting! Thanks!

  4. altic-dev commented on Oct 1, 2026

    @altic-dev
    Owner

    Also, would like some video before and after or some logs for me to verify - I cannot test it myself as I dont use APIs. Thanks!

  5. andrewmitchell-automations commented on Oct 13, 2026

    @andrewmitchell-automations
    Contributor

    @Conte777 I opened #1134 for this. If no AI request has run for 45 s, the app now opens a new connection instead of reusing the old one. The stall did not happen on my network, so your logs would confirm the fix. Could you test this build: https://github.com/altic-dev/FluidVoice/actions/runs/38431278383/artifacts/11831854864 (install steps are in the comment on #1134)? The build has its own bundle ID, so it runs next to your normal install.

    To compare: use Groq, dictate once, wait about 2 minutes, then dictate again. With the fix, the debug log should show LLMClient: Opening a fresh connection after N s idle and no Retry 1/3 due to -1005. A few rounds of before and after logs would help the maintainer verify it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions