Skip to content

Commit

Permalink
fix: prevent infinite loop
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.
  • Loading branch information
Ihrig committed Oct 25, 2021
1 parent 59117c2 commit 4cbc922
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 4cbc922

Please sign in to comment.