Skip to content

1.2.5 triggers circular reference in grunt config #13

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
TheSpyder opened this issue Aug 22, 2016 · 21 comments
Closed

1.2.5 triggers circular reference in grunt config #13

TheSpyder opened this issue Aug 22, 2016 · 21 comments

Comments

@TheSpyder
Copy link

I haven't created a cut down replication case for this yet, but while I do I thought you might want to start looking into it.

Stack trace from grunt:

Warning: Circular reference detected (.files.src[0]) Use --force to continue.
Error: Circular reference detected (.files.src[0])
  at recurse (/home/ephox/jenkins/workspace/fusebox/node_modules/grunt-legacy-util/index.js:99:15)
  at /home/ephox/jenkins/workspace/fusebox/node_modules/grunt-legacy-util/index.js:110:16
  at Array.map (native)
  at recurse (/home/ephox/jenkins/workspace/fusebox/node_modules/grunt-legacy-util/index.js:109:20)
  at recurse (/home/ephox/jenkins/workspace/fusebox/node_modules/grunt-legacy-util/index.js:119:20)
  at recurse (/home/ephox/jenkins/workspace/fusebox/node_modules/grunt-legacy-util/index.js:119:20)
  at Object.util.recurse (/home/ephox/jenkins/workspace/fusebox/node_modules/grunt-legacy-util/index.js:130:10)
  at Function.config.process (/home/ephox/jenkins/workspace/fusebox/node_modules/grunt/lib/grunt/config.js:52:21)
  at Function.config.get (/home/ephox/jenkins/workspace/fusebox/node_modules/grunt/lib/grunt/config.js:46:17)
  at /home/ephox/jenkins/workspace/fusebox/node_modules/grunt/lib/grunt/config.js:98:19
  at Array.filter (native)
  at Object.config.requires [as requiresConfig] (/home/ephox/jenkins/workspace/fusebox/node_modules/grunt/lib/grunt/config.js:97:40)
  at Object.<anonymous> (/home/ephox/jenkins/workspace/fusebox/node_modules/grunt/lib/grunt/task.js:225:10)
  at Object.thisTask.fn (/home/ephox/jenkins/workspace/fusebox/node_modules/grunt/lib/grunt/task.js:73:16)
  at Object.<anonymous> (/home/ephox/jenkins/workspace/fusebox/node_modules/grunt/lib/util/task.js:294:30)
  at Task.runTaskFn (/home/ephox/jenkins/workspace/fusebox/node_modules/grunt/lib/util/task.js:244:24)
  at Task.<anonymous> (/home/ephox/jenkins/workspace/fusebox/node_modules/grunt/lib/util/task.js:293:12)
  at /home/ephox/jenkins/workspace/fusebox/node_modules/grunt/lib/util/task.js:220:11
  at _combinedTickCallback (internal/process/next_tick.js:67:7)
  at process._tickCallback (internal/process/next_tick.js:98:9)
  at Function.Module.runMain (module.js:449:11)
  at startup (node.js:148:18)
  at node.js:405:3

Analysing my build server logs, the only change in my node dependencies is:

--- passing.txt 2016-08-22 17:29:32.000000000 +1000
+++ failing.txt 2016-08-22 17:28:51.000000000 +1000
@@ -177,8 +177,9 @@
 ├── node-fs@0.1.7
 ├─┬ postcss-calc@5.3.0
 │ ├── postcss-message-helpers@2.0.0
-│ └─┬ reduce-css-calc@1.2.4
+│ └─┬ reduce-css-calc@1.2.5
 │   ├── balanced-match@0.1.0
+│   ├── math-expression-evaluator@1.2.9
 │   └─┬ reduce-function-call@1.0.1
 │     └── balanced-match@0.1.0
 ├─┬ postcss-custom-properties@5.0.1

and I confirmed rolling back to 1.2.4 resolves the grunt error.

@MoOx
Copy link
Owner

MoOx commented Aug 22, 2016

Please provides more informations. It seems you are using postcss-calc so postcss. So your config might help to track down this issue.

@MoOx
Copy link
Owner

MoOx commented Aug 22, 2016

Btw, your stack trace does not contains postcss or reduce-css-calc...

@TheSpyder
Copy link
Author

Yeah. The exception happens when I'm running a task that doesn't involve postcss at all, so it's very confusing. I'm still working on a replication case; I've confirmed on two machines that 1.2.4 works and 1.2.5 throws the exception.

@TheSpyder
Copy link
Author

TheSpyder commented Aug 22, 2016

OK it seems to only happen with multi tasks. I was using jshint but I made a custom one and I can still reproduce it.

I reduced it as far as removing the postcss configuration; all you have to do is require postcss-calc somewhere in the file and then calls to grunt.config() (which is trying to read the config) break.

Gruntfile (just tested in an empty directory):

module.exports = function(grunt) {
  grunt.option('stack', true);

  grunt.registerMultiTask('anything', 'any task will do', function () {
    var myconfig = grunt.config([this.name, this.target]);
  });

  require('postcss-calc');

  grunt.initConfig({
    anything: {
      literally: ['anything']
    }
  });
};

Then run:

npm install postcss-calc grunt
grunt anything

@TheSpyder
Copy link
Author

hmm, I looked at your change and the only thing it really did was pull in that math project, so on a hunch I commented out the var mexp = require("math-expression-evaluator") line. That stops throwing the error.

@TheSpyder
Copy link
Author

TheSpyder commented Aug 22, 2016

Found it - the bug is in the Array.indexOf polyfill. Want me to log it? I don't really have time to create a PR though (I suspect both the implementation is wrong and the check for whether the polyfill is needed).

@MoOx
Copy link
Owner

MoOx commented Aug 22, 2016

What version of node are you using?

@TheSpyder
Copy link
Author

I'm on version 6, our build server is version 5.

@leipert
Copy link

leipert commented Aug 22, 2016

we have similar errors with our gulp tasks, it seems to be related to the polyfill, like @TheSpyder already mentioned:

[10:54:14] TypeError: Cannot read property 'length' of undefined
    at flattenGlob (/Users/leipert/eccenca/user-interface/apps/datamanager/node_modules/glob2base/index.js:9:25)
    at setToBase (/Users/leipert/eccenca/user-interface/apps/datamanager/node_modules/glob2base/index.js:48:12)
    at module.exports (/Users/leipert/eccenca/user-interface/apps/datamanager/node_modules/glob2base/index.js:56:19)
    at Object.gs.createStream (/Users/leipert/eccenca/user-interface/apps/datamanager/node_modules/glob-stream/index.js:34:42)
    at Object.gs.create (/Users/leipert/eccenca/user-interface/apps/datamanager/node_modules/glob-stream/index.js:68:42)
    at Gulp.src (/Users/leipert/eccenca/user-interface/apps/datamanager/node_modules/vinyl-fs/lib/src/index.js:33:23)
    at module.exports (/Users/leipert/eccenca/user-interface/apps/datamanager/node_modules/ecc-gulp-tasks/tasks/licenses-yaml2json.js:10:10)
    at module.exports (/Users/leipert/eccenca/user-interface/apps/datamanager/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Users/leipert/eccenca/user-interface/apps/datamanager/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Users/leipert/eccenca/user-interface/apps/datamanager/node_modules/orchestrator/index.js:214:10)

@MoOx
Copy link
Owner

MoOx commented Aug 22, 2016

From what I understand it's more a bug that should be reported in "math-expression-evaluator" right?

@MoOx
Copy link
Owner

MoOx commented Aug 22, 2016

poke @ankit31894

@MoOx
Copy link
Owner

MoOx commented Aug 22, 2016

@MoOx
Copy link
Owner

MoOx commented Aug 22, 2016

The test should be "Array.prototype.indexOf"?
Can you confirm this change is good for you @TheSpyder @leipert ?

@TheSpyder
Copy link
Author

It's more than that - the implementation is wrong too. I found time to do a PR, just coding up a test now.

@MoOx
Copy link
Owner

MoOx commented Aug 22, 2016

Thank you!

@f111fei
Copy link

f111fei commented Aug 22, 2016

@MoOx we use gulp-cssnano and rimraf in our project. in gulp task get errors:

TypeError: Cannot read property 'length' of undefined
    at Function.glob.hasMagic (/Users/luxiangyu/Jenkins/jobs/wingBuild/egretwing-electron/node_modules/rimraf/node_modules/glob/glob.js:106:29)
    at rimraf (/Users/luxiangyu/Jenkins/jobs/wingBuild/egretwing-electron/node_modules/rimraf/rimraf.js:61:36)
    at rimraf (/Users/luxiangyu/Jenkins/jobs/wingBuild/egretwing-electron/build/lib/util.js:253:3)

gulp-cssnano indirect references to reduce-css-calc, so we can't solve this problem. Can you remove math-expression-evaluator first ? Thank you.

@fengmk2
Copy link

fengmk2 commented Aug 22, 2016

Same problem here, can we revert deps math-expression-evaluator for a hotfix?

@MoOx
Copy link
Owner

MoOx commented Aug 22, 2016

No need for ask for this in multiple places.
security issue > bug
aebe8f7#commitcomment-18721775

@MoOx
Copy link
Owner

MoOx commented Aug 22, 2016

If the patch is not merged today, I will fix the version in postcss-calc until it's merged/released.

@MoOx
Copy link
Owner

MoOx commented Aug 22, 2016

If you guys can try this bugwheels94/math-expression-evaluator#2 (comment) and if that's ok, I can add this into reduce-css-calc as a workaround until the "official" fix gets merged/released.

@TheSpyder
Copy link
Author

Upstream has been fixed, deleting node_modules and reinstalling works for me.

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

No branches or pull requests

5 participants