Skip to content

fix(voice-loop): bound wake-word LISTENING startup with timeout - #915

Open
RealDiligent wants to merge 1 commit into
GeniePod:mainfrom
RealDiligent:fix/critical-issue-wakeword-startup-timeout
Open

fix(voice-loop): bound wake-word LISTENING startup with timeout#915
RealDiligent wants to merge 1 commit into
GeniePod:mainfrom
RealDiligent:fix/critical-issue-wakeword-startup-timeout

Conversation

@RealDiligent

@RealDiligent RealDiligent commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Part of #617

Summary

Wake-word mode waited forever on the first read_line for LISTENING. A hung python3 import/model load wedges voice-loop start with no recovery.

Root cause

run_with_wakeword spawned the wake-word script without kill_on_drop and awaited LISTENING with no deadline.

Fix

  • Set kill_on_drop(true) on the wake-word child.
  • Wrap the startup LISTENING read in a 30s tokio::time::timeout; on timeout kill the child and return an error so the outer restart loop can recover.

Impact

A stuck wake-word Python process no longer blocks voice-loop startup indefinitely.

Test plan

  • Change is localized to wake-word startup; the ongoing WAKE event loop is unchanged.
  • Full workspace cargo test — CI validation required.

Real Behavior Proof

  • I have built and run the affected code locally (or noted why I could not).
  • I have verified the change end-to-end on Jetson hardware.
  • I have NOT verified on Jetson hardware, and I explain the equivalent verification path or validation gap below.

CI-only / static review on Windows dev host (genie-core does not fully compile on Windows). Verification is compile-time correctness plus full workspace CI on Linux.

Summary by CodeRabbit

  • Bug Fixes
    • Improved wake-word listener startup reliability with a 30-second readiness timeout.
    • Prevented lingering background listener processes when startup fails or the listener is stopped.
    • Added clearer error handling for startup timeouts and output read failures.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Wake-word listener startup now terminates dropped child processes and bounds the wait for the LISTENING readiness signal to 30 seconds, with explicit cleanup and errors for stdout failures or timeouts.

Changes

Wake-word listener lifecycle

Layer / File(s) Summary
Bounded readiness and process cleanup
crates/genie-core/src/voice_loop.rs
The Python wake-word listener uses kill_on_drop(true) and a 30-second readiness timeout; stdout failures and timeouts kill the child and return explicit errors.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: bug

Suggested reviewers: dale053, kiannidev, minion1227

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a timeout to wake-word LISTENING startup.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Jul 30, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/genie-core/src/voice_loop.rs`:
- Around line 260-273: Update run_with_wakeword’s wake-word startup handling so
timeout, stdout read errors, and malformed readiness responses kill the child,
then sleep for the configured retry delay and continue the outer restart loop
instead of calling anyhow::bail!. Preserve the successful readiness path and
apply identical retry behavior to all three failure branches.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a1f90c56-0a48-4316-a64d-e0d318f48439

📥 Commits

Reviewing files that changed from the base of the PR and between 02a577d and 9407a2d.

📒 Files selected for processing (1)
  • crates/genie-core/src/voice_loop.rs

Comment on lines +260 to +273
match tokio::time::timeout(WAKEWORD_READY_TIMEOUT, reader.read_line(&mut line)).await {
Ok(Ok(_)) => {}
Ok(Err(e)) => {
let _ = child.kill().await;
anyhow::bail!("wake word listener stdout error: {e}");
}
Err(_) => {
let _ = child.kill().await;
anyhow::bail!(
"wake word listener timed out waiting for LISTENING after {}s",
WAKEWORD_READY_TIMEOUT.as_secs()
);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Retry startup failures instead of exiting voice mode.

After killing the child, anyhow::bail! returns from run_with_wakeword; therefore the outer restart loop at Line 225 never spawns a replacement. A hung import/model load will stop voice mode rather than recover. Route timeout/read failures through the retry path (sleep and continue), and apply the same handling to the malformed readiness branch at Lines 274-278.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/genie-core/src/voice_loop.rs` around lines 260 - 273, Update
run_with_wakeword’s wake-word startup handling so timeout, stdout read errors,
and malformed readiness responses kill the child, then sleep for the configured
retry delay and continue the outer restart loop instead of calling
anyhow::bail!. Preserve the successful readiness path and apply identical retry
behavior to all three failure branches.

Part of GeniePod#617: run_with_wakeword waited forever on the first read_line for
LISTENING, so a hung python3 import wedged voice-loop start. Add
kill_on_drop and a 30s timeout that kills the child and returns an error
so the outer restart loop can recover.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant