Skip to content

Commit

Permalink
fix: prevent infinite loop (#8540)
Browse files Browse the repository at this point in the history
The loop in getResourcesToBeCreated() pushes items into the
array that it is iterating over. However, there was no check
for cycles, meaning that circular dependencies pushes resources
into the array until an out of memory error occurs. This commit
adds a check to prevent adding the same item to the array more
than once.

Co-authored-by: Ihrig <[email protected]>
  • Loading branch information
cjihrig and Ihrig authored Oct 26, 2021
1 parent 01f18e4 commit aeaceab
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ export function getResourcesToBeCreated(amplifyMeta, currentAmplifyMeta, categor
(!amplifyMeta[dependsOnCategory][dependsOnResourcename]?.lastPushTimeStamp ||
!currentAmplifyMeta[dependsOnCategory] ||
!currentAmplifyMeta[dependsOnCategory][dependsOnResourcename]) &&
amplifyMeta[dependsOnCategory][dependsOnResourcename].serviceType !== 'imported'
amplifyMeta[dependsOnCategory][dependsOnResourcename].serviceType !== 'imported' &&
!resources.includes(amplifyMeta[dependsOnCategory][dependsOnResourcename])
) {
resources.push(amplifyMeta[dependsOnCategory][dependsOnResourcename]);
}
Expand Down

0 comments on commit aeaceab

Please sign in to comment.