Skip to content

fix(core): clean up startup timeout task#2407

Open
NgoQuocViet2001 wants to merge 1 commit into
tinyhumansai:mainfrom
NgoQuocViet2001:ai/core-startup-timeout-cleanup
Open

fix(core): clean up startup timeout task#2407
NgoQuocViet2001 wants to merge 1 commit into
tinyhumansai:mainfrom
NgoQuocViet2001:ai/core-startup-timeout-cleanup

Conversation

@NgoQuocViet2001
Copy link
Copy Markdown
Contributor

@NgoQuocViet2001 NgoQuocViet2001 commented May 21, 2026

Summary

  • Replace the embedded core readiness loop magic numbers with named constants and do one final non-sleeping ready/port check before timing out.
  • When startup times out, log the ready signal, port, and task state, cancel the shutdown token, and abort/clear the managed task slot so a later retry can spawn cleanly.
  • Add a focused unit test for timeout cleanup behavior.

Context

This targets the local embedded core startup timeout path behind errors like core process did not become ready (for example #2397) and should also make related CI flakes easier to diagnose.

Validation

  • cargo fmt --manifest-path app/src-tauri/Cargo.toml -p OpenHuman --check
  • git diff --check -- app/src-tauri/src/core_process.rs app/src-tauri/src/core_process_tests.rs
  • Attempted: GGML_NATIVE=OFF cargo test --manifest-path app/src-tauri/Cargo.toml startup_timeout_cleanup_aborts_task_and_clears_slot --lib
    • Blocked locally because whisper-rs-sys could not find clang.dll/libclang.dll; the error asks to set LIBCLANG_PATH.

Maintainer edits are enabled.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Enhanced startup error diagnostics with detailed system state information during timeouts.
  • Tests

    • Added test coverage for startup timeout cleanup and proper resource release.

Review Change Stack

@NgoQuocViet2001 NgoQuocViet2001 requested a review from a team May 21, 2026 02:45
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c7f059f9-b463-4e20-bb12-5dcf99fa9115

📥 Commits

Reviewing files that changed from the base of the PR and between 6281aea and 8a2ba96.

📒 Files selected for processing (2)
  • app/src-tauri/src/core_process.rs
  • app/src-tauri/src/core_process_tests.rs

📝 Walkthrough

Walkthrough

The PR parameterizes JSON-RPC readiness polling with named constants, refactors the startup timeout handler to capture detailed diagnostics (readiness signal, port status, task state) before cleanup, and adds a test validating that timeout cleanup clears the task slot and cancels the shutdown token.

Changes

Startup timeout and readiness polling refactor

Layer / File(s) Summary
Polling constants and loop parameterization
app/src-tauri/src/core_process.rs
Named constants define poll interval, max attempts, and derived timeout budget. Readiness loop iteration and documentation updated to use CORE_READY_ATTEMPTS constant instead of hard-coded values.
Timeout diagnostic logging and cleanup
app/src-tauri/src/core_process.rs
Refactored startup timeout path performs final non-sleeping readiness check, captures port-open status and task state, logs diagnostic message with all three fields, then cancels shutdown token and aborts embedded server task before returning detailed error string.
Cleanup behavior validation test
app/src-tauri/src/core_process_tests.rs
New async test wires mock long-running task into CoreProcessHandle, invokes cleanup_startup_timeout, and validates diagnostic fields in timeout message, task slot is cleared, and shutdown token is cancelled.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🐰 Time to polish the startup dance,
With numbered retries and a second glance,
Diagnostics logged when things go wrong,
Tasks cleaned up and moving along!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding cleanup logic for the startup timeout task in the core module, which aligns with the refactored timeout handling that performs final checks, logs details, cancels shutdown tokens, and aborts the task.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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.

1 participant