Skip to content

fix: prevent duplicate project starts#27

Merged
AboMeezO merged 1 commit into
mainfrom
fix/project-start-race
Jun 13, 2026
Merged

fix: prevent duplicate project starts#27
AboMeezO merged 1 commit into
mainfrom
fix/project-start-race

Conversation

@AboMeezO

@AboMeezO AboMeezO commented Jun 12, 2026

Copy link
Copy Markdown
Member

Summary

  • Add a per-project startup lock so concurrent start requests share the same in-flight start.

Bug

Rapid duplicate start requests can pass the running-project guard before startup records the runtime, spawning duplicate process trees for one project.

Solution

Track in-flight starts by project id and clear the lock after startup completes or fails.

Tests

  • npm run typecheck
  • npm run lint
  • npm run build:web

Summary by CodeRabbit

  • Bug Fixes
    • Improved project startup reliability by preventing duplicate start operations when multiple concurrent requests occur for the same project.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1b81e7ce-e4a9-4d67-8931-b5ae835ae591

📥 Commits

Reviewing files that changed from the base of the PR and between 1c12e3c and c544f51.

📒 Files selected for processing (1)
  • electron/services/projectsManager.js

📝 Walkthrough

Walkthrough

This PR adds a concurrency guard to the startProject function in the projects manager service. A module-level startLocks Map now tracks in-flight start promises per project id, allowing concurrent calls with the same id to return and await the same promise instead of spawning duplicate start operations.

Changes

Concurrent Project Start Deduplication

Layer / File(s) Summary
Start lock mechanism
electron/services/projectsManager.js
Module-level startLocks Map caches in-flight startProjectUnlocked(id) promises by stringified id. The exported startProject function checks for an existing promise, returns it if found, or stores a new promise and cleans up the cache entry in finally after completion.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Two starts that race now run as one,
A lock in memory, their work is done.
One promise shared, no paths that fork—
Together they complete the work! 🔒✨

🚥 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 'fix: prevent duplicate project starts' directly and clearly summarizes the main change: introducing a locking mechanism to prevent concurrent start requests from creating duplicate projects.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/project-start-race

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.

@AboMeezO
AboMeezO merged commit 03c44c4 into main Jun 13, 2026
1 of 2 checks passed
@AboMeezO
AboMeezO deleted the fix/project-start-race branch June 13, 2026 10:42
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