Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm translator: Fix endless loop in case of dependency cycles #15

Merged
merged 1 commit into from
Jun 26, 2018

Conversation

codeworrior
Copy link
Member

@CLAassistant
Copy link

CLAassistant commented Jun 23, 2018

CLA assistant check
All committers have signed the CLA.

@codeworrior codeworrior force-pushed the avoid-endless-loop-for-dependency-cycles branch from de9c8ac to 3bb69f0 Compare June 23, 2018 22:12
Copy link
Member

@RandomByte RandomByte left a comment

Choose a reason for hiding this comment

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

I was wondering why I didn't implement something similar when we first faced the circular dependency issue last year. But I guess this solution only got possible due to a more recent refactoring that lead to the processPendingDeps function being implemented.

Could you please add a [FIX] prefix to the commit message and maybe remove the spaces in the if-statement to follow the general code style?

Copy link
Member

@RandomByte RandomByte left a comment

Choose a reason for hiding this comment

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

Meant to request changes... See approval comment

@codeworrior codeworrior force-pushed the avoid-endless-loop-for-dependency-cycles branch from 3bb69f0 to 0d8ed08 Compare June 25, 2018 19:45

// Breadth-first search to prefer projects closer to root
while (queue.length) {
const project = queue.shift(); // Get and remove first entry from queue
if (!project.id) {
throw new Error("Encountered project with missing id");
}
if (visited.has(project.id)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Would it make sense to to check for the combination of project.id and project.version instead of only the project.id?

Copy link
Member

Choose a reason for hiding this comment

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

The projectPreprocessor does the same also on id-level: projectPreprocessor.js#L55. So I guess it wouldn't change much down that line.

While it is yet to be decided and documented, we once agreed (for the time being) to always prefer the projects closer to the root, ignoring the version.

Copy link
Member

@RandomByte RandomByte left a comment

Choose a reason for hiding this comment

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

As per our Guidelines we prefer the commit message summary prefix to be uppercase 😉

Btw. I'm not sure whether our changelog would even include commits with a lower case prefix: .chglog/config.yml#L11

@codeworrior codeworrior force-pushed the avoid-endless-loop-for-dependency-cycles branch from 0d8ed08 to c5905b1 Compare June 25, 2018 20:06
@codeworrior
Copy link
Member Author

How could I miss that...

@codeworrior codeworrior merged commit cf31112 into master Jun 26, 2018
@codeworrior codeworrior deleted the avoid-endless-loop-for-dependency-cycles branch June 26, 2018 07:05
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.

3 participants