Skip to content

Conversation

Copy link

Copilot AI commented Dec 5, 2025

The async callbacks in forEach loops weren't being awaited, causing race conditions in package cache construction and dependency graph building.

Changes

  • Replaced async forEach with for...of loops: Ensures synchronous execution where package cache and dependency relationships must complete before proceeding
  • Updated control flow: Changed return to continue for loop contexts
  • Added type safety: Introduced TopLevelReferrer type and replaced empty array types [] with proper types (TopLevelReferrer[], string[])

Example

// Before - async callback not awaited
componentsFound.forEach(async (component: any) => {
  const pkg = new ComponentDetectionPackage(...);
  packageCache.addPackage(pkg);
  return; // early exit
});

// After - synchronous for...of loop
for (const component of componentsFound) {
  const pkg = new ComponentDetectionPackage(...);
  packageCache.addPackage(pkg);
  continue; // early exit
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 5, 2025 15:15
Co-authored-by: aegilops <41705651+aegilops@users.noreply.github.com>
Co-authored-by: aegilops <41705651+aegilops@users.noreply.github.com>
Copilot AI changed the title [WIP] Update to address feedback on dependency review PR Fix race conditions from unawaited async forEach callbacks Dec 5, 2025
Copilot AI requested a review from aegilops December 5, 2025 15:22
Copilot finished work on behalf of aegilops December 5, 2025 15:22
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