Skip to content

fix(worker): exit after max connection retries#1889

Open
rosetta-livekit-bot[bot] wants to merge 1 commit into
mainfrom
armory-waxed-oinks
Open

fix(worker): exit after max connection retries#1889
rosetta-livekit-bot[bot] wants to merge 1 commit into
mainfrom
armory-waxed-oinks

Conversation

@rosetta-livekit-bot

@rosetta-livekit-bot rosetta-livekit-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Testing

  • pnpm test agents/src/worker.test.ts
  • pnpm build:agents
  • pnpm --filter @livekit/agents lint (existing warnings only)

Ported from livekit/agents#6103

Original PR description

Fixes #6083.

When the worker connects to a wrong or unreachable URL, it never exits after exhausting max_retry — it hangs as a zombie, and a user try/except around server.run() never catches the error.

AgentServer.run() completes only when _close_future resolves, which happens exclusively in aclose(). The connection task is fire-and-forget: it's created and appended to a local tasks list that is never awaited or watched. When _connection_task exhausts max_retry it raises RuntimeError, but that exception dies on the orphaned task. Nothing resolves _close_future, so run() blocks forever, the CLI's except Exception never fires (no drain/exit), and callers' try/except catches nothing.

This adds a done callback on the connection task that propagates its terminal exception to _close_future, so run() re-raises it. The CLI then logs worker failed and runs its normal drain/aclose teardown so the process exits, and a user try/except around server.run() finally catches the failure.

Scoped to the connection task only — not the load task, whose failures are logged-and-continue today and should not start crashing the worker.

@changeset-bot

changeset-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7ab52ca

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 35 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rosetta-livekit-bot rosetta-livekit-bot Bot requested a review from longcw June 26, 2026 11:55

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

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.

0 participants