fix(tauri): harden Windows pre-CEF single-instance mutex handling#2669
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Windows single-instance mutex guard in ChangesWindows mutex error handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsStopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a Comment |
Summary
Hardens the Windows pre-CEF single-instance guard in app/src-tauri/src/lib.rs to better handle Win32 edge cases.
Captures GetLastError() immediately after CreateMutexW so the mutex result cannot be clobbered by later calls.
Adds explicit CreateMutexW == NULL handling with an error log and best-effort continuation.
Preserves existing secondary-instance early-exit behavior (ERROR_ALREADY_EXISTS) and deep-link forwarding path.
Problem
On Windows, this guard exists to prevent secondary launches from reaching cef::initialize() and triggering the known panic path (OPENHUMAN-TAURI-A).
The previous logic relied on reading GetLastError() inline and did not explicitly handle a NULL mutex handle path with strong observability.
That made rare Win32 failure modes harder to diagnose and increased risk of unclear startup behavior during concurrency.
Solution
Read and store last_error immediately after CreateMutexW.
Branch explicitly for handle.is_null(), log the Win32 error, and continue startup best-effort rather than crashing early.
Keep the ERROR_ALREADY_EXISTS branch as the authoritative secondary-instance exit path, including deep-link forwarding attempt before exit.
Retain RAII mutex ownership for the primary instance so handle lifetime is clean and deterministic.
Submission Checklist
If a section does not apply to this change, mark the item as N/A with a one-line reason. Do not delete items.
Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
Diff coverage ≥ 80% — changed lines (Vitest + cargo-llvm-cov merged via diff-cover) meet the gate enforced by
.github/workflows/coverage.yml. Run pnpm test:coverage and pnpm test:rust locally; PRs below 80% on changed lines will not merge.Coverage matrix updated — added/removed/renamed feature rows in
docs/TEST-COVERAGE-MATRIX.mdreflect this change (or N/A: behaviour-only change)All affected feature IDs from the matrix are listed in the PR description under ## Related
No new external network dependencies introduced (mock backend used per Testing Strategy)
Manual smoke checklist updated if this touches release-cut surfaces (
docs/RELEASE-MANUAL-SMOKE.md)Linked issue closed via Closes #NNN in the ## Related section
Impact
Platform/runtime: Windows desktop Tauri startup path only; no intended behavior change on macOS/Linux.
Security/compatibility: improves failure observability and startup robustness; no API or config migration required.
Performance: negligible (one extra error-code capture and logging only on failure path).
Summary by CodeRabbit