1

I got this error:

angular.js:4767 Uncaught RangeError: Maximum call stack size exceeded
    at Object.invoke (angular.js:4767)
    at angular.js:4574
    at forEach (angular.js:325)
    at createInjector (angular.js:4574)
    at doBootstrap (angular.js:1805)
    at bootstrap (angular.js:1826)
    at angularInit (angular.js:1711)
    at HTMLDocument.<anonymous> (angular.js:32539)
    at fire (jquery.js:3187)
    at Object.fireWith [as resolveWith] (jquery.js:3317)

I know it is not a loop in my code because the same project works in other environments, so I suspect the problem is in my node or grunt.

node v5.3.0
grunt v0.4.5
grunt-cli v1.2.0

Here is the grunt command for dev:

grunt.registerTask('dev', ['ngconstant:dev', 'dom_munger:read', 'jshint', 'ngtemplates', 'less', 'connect', 'watch']);

and packages.json:

{
  "name": "myapp.maso.app",
  "version": "1.0.0-beta.172",
  "repository": {
    "type": "git",
    "url": ""
  },
  "devDependencies": {
    "chai": "^3.5.0",
    "chromedriver": "~2.21.2",
    "grunt": "~0.4.5",
    "grunt-angular-templates": "~1.0.3",
    "grunt-browser-output": "1.0.3",
    "grunt-connect-proxy": "^0.2.0",
    "grunt-contrib-clean": "~1.0.0",
    "grunt-contrib-concat": "~1.0.0",
    "grunt-contrib-connect": "~1.0.0",
    "grunt-contrib-copy": "~1.0.0",
    "grunt-contrib-cssmin": "~1.0.1",
    "grunt-contrib-htmlmin": "~1.1.0",
    "grunt-contrib-imagemin": "~1.0.0",
    "grunt-contrib-jshint": "~1.0.0",
    "grunt-contrib-less": "^1.2.0",
    "grunt-contrib-uglify": "~1.0.1",
    "grunt-contrib-watch": "~1.0.0",
    "grunt-dom-munger": "~3.4",
    "grunt-karma": "~0.12.2",
    "grunt-manifest": "^0.4.4",
    "grunt-ng-annotate": "^2.0.1",
    "grunt-ng-constant": "^2.0.1",
    "grunt-npm-install": "^0.3.1",
    "grunt-protractor-runner": "~3.0.0",
    "grunt-serve": "^0.1.6",
    "grunt-version": "^1.0.0",
    "jshint-stylish": "^2.1.0",
    "karma": "^0.13.22",
    "karma-chai": "^0.1.0",
    "karma-chrome-launcher": "~0.2.2",
    "karma-firefox-launcher": "~0.1.7",
    "karma-jasmine": "~0.3.8",
    "karma-mocha": "^0.2.2",
    "karma-mocha-reporter": "~2.0.0",
    "karma-ng-html2js-preprocessor": "^0.2.1",
    "karma-ng-json2js-preprocessor": "^1.1.2",
    "karma-phantomjs-launcher": "^1.0.0",
    "less": "^2.6.1",
    "load-grunt-tasks": "~3.4.1",
    "mocha": "^2.4.5",
    "protractor": "~3.2.1",
    "webdriver-manager": "~8.0.0"
  }
}

If anyone can help my debug this, I have tries many other questions and GitHub issues and still I can't solve this.

If there is more information needed please comment below.

EDIT - all my grunt tasks:

grunt.registerTask('dev', ['ngconstant:dev', 'dom_munger:read', 'jshint', 'ngtemplates', 'less', 'connect', 'watch']);
grunt.registerTask('live', ['ngconstant:live', 'dom_munger:read', 'jshint', 'ngtemplates', 'less', 'connect', 'watch']);

// isracard development environment
grunt.registerTask('devi', ['ngconstant:devi', 'dom_munger:read', 'jshint', 'less', 'connect', 'watch']);
grunt.registerTask('livei', ['ngconstant:livei', 'dom_munger:read', 'jshint', 'less', 'connect', 'watch']);
grunt.registerTask('forms', ['ngconstant:forms', 'dom_munger:read', 'jshint', 'less', 'connect', 'watch']);

// build
grunt.registerTask('build', ['ngconstant:live', 'version:project:prerelease', 'jshint', 'clean:before', 'less', 'dom_munger', 'ngtemplates', 'cssmin', 'concat', 'ngAnnotate', 'copy', 'htmlmin', 'manifest', 'clean:after']);

grunt.registerTask('test', ['ngconstant:mock', 'dom_munger:read', 'karma:all_tests']);
grunt.registerTask('e2e', ['dom_munger:read', 'protractor']);

Many thanks.

Itsik Mauyhas
  • 3,824
  • 14
  • 69
  • 114

2 Answers2

0

Well, the GruntJS FAQ says that,

You probably created an alias task with the same name as one of your regular tasks

Example: grunt.registerTask('uglify', ['uglify:my_target']); should be grunt.registerTask('myUglify', ['uglify:my_target']);.

Please check if you have made any mistakes as such.

Hope this helps!

David R
  • 14,711
  • 7
  • 54
  • 72
0

So this means you have exceeded the maximum number of calls allowed by the JS engine. This could mean one of two things:

  1. You have some infinite recursive loop somewhere-- a function that keeps calling itself without ever breaking/exiting, or even a group of functions calling each other in a circle in a similar manner. At a certain point the engine says enough is enough, and exits.
  2. Alternately, if you are using some sort of task that is splitting up files (think templates or JSON) by line into strings and concatenating them together in Javascript, it is possible you have a file that is so many lines long that the sheer number of + operators used causes the stack size to overflow. I have run into this myself a few times myself when attempting to inject mock data into Karma tests-- apparently 11,000 lines is too many to add together.

Unfortunately, there is not a great way to test this other than attempting to isolate your code bit by bit and see if you can track down the issue. One thing that could help is using the node-inspector tool and setting it to break before throwing an error like you would in Chrome-- then you can investigate the call stack and see if you can learn anything by tracing it back. Good luck!

(Please note, this is not an exclusive list-- there could be other causes-- these are just the two I have encountered most frequently).

Alexander Nied
  • 12,804
  • 4
  • 25
  • 45
  • Hi, as I said the project runs on other development environments, so to narrow down the causes I think it is somewhere in my grunt or node settings. – Itsik Mauyhas Jan 12 '17 at 14:20
  • There are no different files used in the different environments? – Alexander Nied Jan 12 '17 at 14:21
  • No, the same git repository. – Itsik Mauyhas Jan 12 '17 at 14:22
  • Well, the [node-inspector](https://github.com/node-inspector/node-inspector) _may_ still yield some useful information-- even if it is just a setting, seeing where it is breaking might give you an opportunity to gain some insight into where things are going wrong. – Alexander Nied Jan 12 '17 at 14:25
  • It is a web project, I am getting this error in my chrome console. – Itsik Mauyhas Jan 12 '17 at 14:29
  • So have you tried toggling "pause on exceptions" to see if you can walk back through the stack in the dev tools and get a sense of what is happening? – Alexander Nied Jan 12 '17 at 14:55
  • Also, I assume you've reviewed these already? [SO1](http://stackoverflow.com/questions/15962684/rangeerror-maximum-call-stack-size-exceeded) & [SO2](http://stackoverflow.com/questions/25028597/how-can-i-fix-maximum-call-stack-size-exceeded-angularjs)? – Alexander Nied Jan 12 '17 at 14:56