Skip to content

Fix a 5 second delay for the first listener on an idle serve worker - #316

Merged
maximmaxim345 merged 2 commits into
mainfrom
fix/serve-idle-worker-start-delay
Oct 28, 2026
Merged

maximmaxim345 merged 2 commits into
mainfrom
fix/serve-idle-worker-start-delay

Conversation

@maximmaxim345

Copy link
Copy Markdown
Member

What does this implement/fix?

With sendspin serve --workers, a listener joining a worker that had no other listeners heard nothing for about 5 seconds while another worker was already playing. The idle worker dropped all audio until its first listener arrived, so the first audio it sent was scheduled about 5 seconds ahead.

Workers now keep the audio that hasn't played yet, without encoding it, and hand it to a new stream so playback starts right away.

Related issue (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue): bugfix
  • New feature (non-breaking change which adds functionality): new-feature
  • Enhancement to an existing feature: enhancement
  • Breaking change (changes CLI options, settings, hooks or the protocol in a way that is not backwards compatible): breaking-change
  • Refactor (no behavior change): refactor
  • Documentation only: documentation
  • Maintenance / chore: maintenance
  • CI / workflow change: ci
  • Dependencies bump: dependencies

With multiple workers, a listener joining a worker with no other
listeners heard nothing for about 5 seconds.
Copilot AI balanced review requested due to automatic review settings October 28, 2026 07:37
@github-actions github-actions Bot added the bugfix Fixes a bug label Oct 28, 2026

Copilot AI 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.

🔵 Needs a closer look

Mock-only tests do not verify the pinned aiosendspin PushStream history and timestamp semantics needed for prompt, synchronized playback when joining an idle worker in a real multi-worker session.

No open issues 🎉

What changed in this PR

Fixes the roughly five-second playback delay when the first listener joins an idle worker while another worker is already playing in sendspin serve --workers.

Changes:

  • Retains unplayed audio without encoding it and supplies it as history when a new stream starts.
  • Discards expired chunks and clears retained audio when the source timeline changes.
  • Adds tests for replaying recent audio and excluding chunks from a previous timeline.
File Description
tests/​serve/​test_worker.py Tests historical audio replay and timeline reset handling.
sendspin/​serve/​worker.py Buffers unplayed audio and prepares it for newly active streams.

Review effort: Balanced

@maximmaxim345
maximmaxim345 merged commit edffa50 into main Oct 28, 2026
4 checks passed
@maximmaxim345
maximmaxim345 deleted the fix/serve-idle-worker-start-delay branch October 28, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants