Skip to content

Conversation

@fubhy
Copy link
Contributor

@fubhy fubhy commented Jan 12, 2026

This attempts to tackle a race condition I ran into in CI multiple times whilst working on the last fix.

Copilot AI review requested due to automatic review settings January 12, 2026 23:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a race condition in the ProjectCollection by ensuring that configFileRegistry and apiOpenedProjects fields are properly cloned before modification. The issue was that these two fields were missing from the clone() method and were being directly modified in Finalize() without ensuring a proper clone, which could lead to concurrent access issues when the old ProjectCollection is still being read while a new one is being built.

Changes:

  • Added conditional cloning logic in Finalize() for configFileRegistry and apiOpenedProjects fields
  • Updated the clone() method to include the previously missing configFileRegistry and apiOpenedProjects fields

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/project/projectcollectionbuilder.go Added conditional cloning checks before modifying configFileRegistry and apiOpenedProjects to prevent race conditions
internal/project/projectcollection.go Added missing configFileRegistry and apiOpenedProjects fields to the clone() method to ensure proper shallow copying

@fubhy
Copy link
Contributor Author

fubhy commented Jan 13, 2026

There seem to be more, unrelated race conditions e.g. https://github.com/microsoft/typescript-go/actions/runs/20938617746/job/60167089124 that the previous CI run ran into. That one appears to be a problem with the scope of the mutex in flushChanges.

@fubhy
Copy link
Contributor Author

fubhy commented Jan 13, 2026

There seem to be more, unrelated race conditions e.g. https://github.com/microsoft/typescript-go/actions/runs/20938617746/job/60167089124 that the previous CI run ran into. That one appears to be a problem with the scope of the mutex in flushChanges.

Attempting to fix that here: #2495

@andrewbranch andrewbranch added this pull request to the merge queue Jan 15, 2026
Merged via the queue into microsoft:main with commit b9bf093 Jan 15, 2026
22 checks passed
@fubhy fubhy deleted the fix-race-condition branch January 16, 2026 07:00
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