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

Markdown reporter error: Maximum call stack size exceeded #1875

Closed
baldercm opened this issue Sep 9, 2015 · 1 comment
Closed

Markdown reporter error: Maximum call stack size exceeded #1875

baldercm opened this issue Sep 9, 2015 · 1 comment

Comments

@baldercm
Copy link

baldercm commented Sep 9, 2015

We are using Markdown reporter for our Mocha tests and started having troubles with version 2.3.0 and above. There seems to be an infinite recursion in Markdown reporter:

$ NODE_ENV=test ./node_modules/.bin/mocha --reporter markdown >> docs/README.md

/home/balder/git/payments/node_modules/mocha/lib/reporters/markdown.js:40
    obj = obj[key] = obj[key] || { suite: suite };
                        ^

RangeError: Maximum call stack size exceeded
  at mapTOC (/home/balder/git/payments/node_modules/mocha/lib/reporters/markdown.js:40:25)
  at /home/balder/git/payments/node_modules/mocha/lib/reporters/markdown.js:42:7
  at Array.forEach (native)
  at mapTOC (/home/balder/git/payments/node_modules/mocha/lib/reporters/markdown.js:41:18)
  at /home/balder/git/payments/node_modules/mocha/lib/reporters/markdown.js:42:7

Apparently, the issues started with commit 3f78f10, with the changes in the mapTOC function in lib/reporters/markdown.js, more precisely, deletion of callback parameter in the foreach loop:

function mapTOC(suite, obj) {
    var ret = obj;
    var key = SUITE_PREFIX + suite.title;

    obj = obj[key] = obj[key] || { suite: suite };
    suite.suites.forEach(function() { // suite param missing leads to infinite recursion
      mapTOC(suite, obj);
    });

    return ret;
  }

I have tested locally and adding the param back fixes the issue.

@danielstjules
Copy link
Contributor

Thanks for letting us know! I'll hopefully merge this fix in shortly #1876

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

2 participants