Skip to content

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

Merged
senamakel merged 3 commits into
tinyhumansai:mainfrom
NgoQuocViet2001:ai/core-startup-timeout-cleanup
May 23, 2026
Merged

fix(core): clean up startup timeout task#2407
senamakel merged 3 commits 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

  • Bug Fixes

    • Improved startup timeout handling: clearer diagnostic messages on failure, proper cleanup of stalled startup tasks, and freed resources so retries can proceed reliably.
  • Tests

    • Added test coverage for startup timeout cleanup, task aborting, and resource-release behavior.

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: e4cdf2d8-37f4-4106-96b4-65e8dde17b6b

📥 Commits

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

📒 Files selected for processing (1)
  • app/src-tauri/src/core_process.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.
Readiness loop iteration update
app/src-tauri/src/core_process.rs
Readiness loop changed to iterate over CORE_READY_ATTEMPTS and comments updated to reflect the new readiness budget.
Polling sleep and final non-sleep check
app/src-tauri/src/core_process.rs
Inserted fixed sleep of CORE_READY_POLL_MS between polling iterations and added a final non-sleeping readiness check; computed port-open status once before timeout cleanup.
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 'fix(core): clean up startup timeout task' directly describes the main change: adding cleanup logic for startup timeout handling, which is the primary objective of the PR.
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.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 21, 2026
@senamakel senamakel self-assigned this May 23, 2026
# Conflicts:
#	app/src-tauri/src/core_process.rs
@senamakel senamakel merged commit b47b71e into tinyhumansai:main May 23, 2026
23 of 24 checks passed
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.

2 participants