Skip to content

postcss-values-parser hangs indefinitely #112

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

Closed
mjhenkes opened this issue Apr 22, 2020 · 5 comments · Fixed by #114
Closed

postcss-values-parser hangs indefinitely #112

mjhenkes opened this issue Apr 22, 2020 · 5 comments · Fixed by #114

Comments

@mjhenkes
Copy link

  • Operating System (or Browser): MacOS 10.13.6
  • Node Version: 10
  • postcss-values-parser Version: 3.2.0

How Do We Reproduce?

You can reproduce the issue with the following script:

const { parse } = require('postcss-values-parser');

const output = parse('derp-face(#0366d6)');

console.log('Output:', output);

How we got into this situation was that we had an undefined (bad) mixin that didn't get resolved and got passed to the values parser. Previously in version 3.1.1 the bad mixin was just ignored, now postcss-values-parser and by relation, webpack hangs indefinitely. We've fixed the bad mixin on our side but some other teams we work with have started seeing the issue. I don't think hanging indefinitely was intended even if this is unexpected css. At a minimum we should probably throw an error if this string is not ok.

Of note: this only breaks if there is a dash in the unresolved mixin.

Expected Behavior

The previous output of the function was:

Root {
  raws: { semicolon: false, after: '' },
  type: 'root',
  nodes:
   [ Func {
       raws: [Object],
       name: 'derp-face',
       type: 'func',
       isColor: false,
       isVar: false,
       nodes: [Array],
       parent: [Circular],
       source: [Object],
       params: '(#0366d6)' } ],
  source:
   { input:
      Input { css: 'derp-face(#0366d6)', hasBOM: false, id: '<input css 1>' },
     start: { line: 1, column: 1 } },
  toString: [Function: bound toString] }

Actual Behavior

The parser hangs indefinitely.

@shellscape
Copy link
Owner

Thanks for reporting. Are you able to downgrade to the previous version to see if it's a regression that was introduced?

@mjhenkes
Copy link
Author

Yes, downgrading to v3.1.1 does not hang and gives the output I posted above.

@processwired
Copy link

I'm experiencing the issue as well. postcss-values-parser v3.2.0 as a depency to postcss-custom-properties leads to infinite hangs as soon as a property is set by postcss-custom-properties to be used in postcss-inline-svg. For example this does not work with v3.2.0:

:root {
    --color-white: #fff;
}

.icon {
    background-image: svg-load('icon.svg', fill: var(--color-white));
}

The same works with postcss-values-parser 3.1.1 when explicitly set to package.json:

"dependencies": {
       "postcss-values-parser": "3.1.1",
}

@shellscape
Copy link
Owner

Happy to review a PR that resolves this.

shellscape added a commit that referenced this issue Apr 25, 2020
shellscape added a commit that referenced this issue Apr 26, 2020
Credit goes to @jonathantneal for identifying the offending code and cause.
@mjhenkes
Copy link
Author

@shellscape Thanks for the fix!

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

Successfully merging a pull request may close this issue.

3 participants