jest icon indicating copy to clipboard operation
jest copied to clipboard

RangeError when running jest with NODE_DEBUG=module

Open capaj opened this issue 6 years ago • 4 comments

🐛 Bug Report

Determining test suites to run...MODULE 2341: Module._load REQUEST jest-haste-map parent: /home/capaj/git_projects/looop/project-alpha/node_modules/jest/node_modules/jest-cli/build/TestSequencer.js
MODULE 2341: looking for "jest-haste-map" in ["/home/capaj/git_projects/looop/project-alpha/node_modules/jest/node_modules/jest-cli/build/node_modules","/home/capaj/git_projects/looop/project-alpha/node_modules/jest/node_modules/jest-cli/node_modules","/home/capaj/git_projects/looop/project-alpha/node_modules/jest/node_modules","/home/capaj/git_projects/looop/project-alpha/node_modules","/home/capaj/git_projects/looop/node_modules","/home/capaj/git_projects/node_modules","/home/capaj/node_modules","/home/node_modules","/node_modules","/home/capaj/.node_modules","/home/capaj/.node_libraries","/home/capaj/.nvm/versions/node/v10.15.1/lib/node"]
MODULE 2341: Module._load REQUEST fs parent: /home/capaj/git_projects/looop/project-alpha/node_modules/jest/node_modules/jest-cli/build/TestSequencer.js
MODULE 2341: load native module fs
MODULE 2341: Module._load REQUEST p-each-series parent: /home/capaj/git_projects/looop/project-alpha/node_modules/jest/node_modules/jest-cli/build/runGlobalHook.js
MODULE 2341: looking for "p-each-series" in ["/home/capaj/git_projects/looop/project-alpha/node_modules/jest/node_modules/jest-cli/build/node_modules","/home/capaj/git_projects/looop/project-alpha/node_modules/jest/node_modules/jest-cli/node_modules","/home/capaj/git_projects/looop/project-alpha/node_modules/jest/node_modules","/home/capaj/git_projects/looop/project-alpha/node_modules","/home/capaj/git_projects/looop/node_modules","/home/capaj/git_projects/node_modules","/home/capaj/node_modules","/home/node_modules","/node_modules","/home/capaj/.node_modules","/home/capaj/.node_libraries","/home/capaj/.nvm/versions/node/v10.15.1/lib/node"]
MODULE 2341: load "/home/capaj/git_projects/looop/project-alpha/node_modules/p-each-series/index.js" for module "/home/capaj/git_projects/looop/project-alpha/node_modules/p-each-series/index.js"
MODULE 2341: Module._load REQUEST p-reduce parent: /home/capaj/git_projects/looop/project-alpha/node_modules/p-each-series/index.js
MODULE 2341: looking for "p-reduce" in ["/home/capaj/git_projects/looop/project-alpha/node_modules/p-each-series/node_modules","/home/capaj/git_projects/looop/project-alpha/node_modules","/home/capaj/git_projects/looop/node_modules","/home/capaj/git_projects/node_modules","/home/capaj/node_modules","/home/node_modules","/node_modules","/home/capaj/.node_modules","/home/capaj/.node_libraries","/home/capaj/.nvm/versions/node/v10.15.1/lib/node"]
MODULE 2341: load "/home/capaj/git_projects/looop/project-alpha/node_modules/p-reduce/index.js" for module "/home/capaj/git_projects/looop/project-alpha/node_modules/p-reduce/index.js"
console.js:169
      throw e;
      ^

RangeError: Maximum call stack size exceeded
    at debug (util.js:188:17)
    at Function.Module._load (internal/modules/cjs/loader.js:504:5)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at _jestUtil (/home/capaj/git_projects/looop/project-alpha/node_modules/jest/node_modules/jest-cli/build/reporters/default_reporter.js:9:16)
    at VerboseReporter._clearStatus (/home/capaj/git_projects/looop/project-alpha/node_modules/jest/node_modules/jest-cli/build/reporters/default_reporter.js:152:9)
    at flushBufferedOutput (/home/capaj/git_projects/looop/project-alpha/node_modules/jest/node_modules/jest-cli/build/reporters/default_reporter.js:85:12)
    at debouncedFlush (/home/capaj/git_projects/looop/project-alpha/node_modules/jest/node_modules/jest-cli/build/reporters/default_reporter.js:103:9)
    at WriteStream.stream.write.chunk [as write] (/home/capaj/git_projects/looop/project-alpha/node_modules/jest/node_modules/jest-cli/build/reporters/default_reporter.js:116:7)
    at write (console.js:164:12)

To Reproduce

run jest with NODE_DEBUG=module

Expected behavior

does not crash

Link to repl or repo (highly encouraged)

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: Linux 4.18 Ubuntu 18.10 (Cosmic Cuttlefish)
    CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
  Binaries:
    Node: 10.15.1 - ~/.nvm/versions/node/v10.15.1/bin/node
    Yarn: 1.13.0 - ~/.yarn/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.15.1/bin/npm
  npmPackages:
    jest: 24.1.0 => 24.1.0 

capaj avatar Mar 03 '19 10:03 capaj

You can add --stacksize=9840 (10x more than the standard value). But it will gonna fail after with an Segmentation Fault error message

Ziggoto avatar Jul 17 '20 14:07 Ziggoto

You can coax it a bit higher too, by bumping up the OS stack size first:

ulimit -s hard
NODE_DEBUG=module node --stack-size=64512 node_modules/.bin/jest

Still isn't enough, even though it sits there spinning for an extra couple seconds. Probably an infinite recursion.

markdascher avatar Sep 17 '21 15:09 markdascher

What actually worked for me was to edit node_modules/@jest/reporters/build/DefaultReporter.js and short-circuit the _clearStatus and _printStatus functions. Guessing the infinite recursion looked something like:

Module load triggers debug message Output triggers DefaultReporter DefaultReporter triggers module load (e.g. jest-util) Module load triggers debug message etc.

Wonder if DefaultReporter.ts could ensure all module loading happens outside of the actual flushBufferedOutput sequence? This behavior doesn't seem obvious from the source code, but the compiled output looks more like this:

function _jestUtil() {
  const data = require('jest-util');

  _jestUtil = function () {
    return data;
  };

  return data;
}

// …

if (_jestUtil().isInteractive) {

Which makes it look like jest-util is lazy-loaded at runtime.

markdascher avatar Sep 17 '21 15:09 markdascher

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Sep 17 '22 15:09 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

github-actions[bot] avatar Oct 17 '22 15:10 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

github-actions[bot] avatar Nov 17 '22 00:11 github-actions[bot]