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

Circular references cause infinite loop in 3.0 #608

Closed
dbanksdesign opened this issue Apr 20, 2021 · 1 comment
Closed

Circular references cause infinite loop in 3.0 #608

dbanksdesign opened this issue Apr 20, 2021 · 1 comment

Comments

@dbanksdesign
Copy link
Member

Steps to reproduce:

  1. Get the 3.0 RC build, npm install style-dictionary@next
  2. Run this code:
const StyleDictionary = require('style-dictionary');

StyleDictionary.extend({
  properties: {
    color: {
      foo: { value: "{color.foo.value}" },
      teal: { value: "{color.blue.value}" },
      blue: { value: "{color.green.value}" },
      green: { value: "{color.teal.value}" },
      purple: { value: "{color.teal.value}" }
    }
  },
  platforms: {
    css: {}
  }
}).buildAllPlatforms();

And then hear your computer fan spin like crazy.

@dbanksdesign dbanksdesign self-assigned this Apr 20, 2021
dbanksdesign added a commit that referenced this issue Apr 26, 2021
Fixes #608 
Due to the changes we made with for transitive transforms, the code that checks for a circular reference was breaking because it was deferring resolution and therefore created an infinite loop of trying to resolve references but deferring some. This change fixes that by keeping track of how many deferred properties there are and if that number does not decrease with a pass then there is a circular reference. We then try to resolve the object one more time, without deferring any references so that the resolveObject method can record the circular references.
@dbanksdesign
Copy link
Member Author

Closing this as it is now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant