Node-fs-extra: [8.0.0] (node:27451) UnhandledPromiseRejectionWarning: RangeError: Maximum call stack size exceeded

Created on 13 May 2019  ·  5Comments  ·  Source: jprichardson/node-fs-extra

  • Operating System: MacOS, 10.14.4
  • Node.js version: 10.6.0
  • fs-extra version: 8.0.0

I'm failing at a relatively innocuous looking line:

await fse.copy(path.join(__dirname, '..', 'book', 'templates'), path.join('.', title, 'templates')).catch(err => console.log(err))

The process simply hangs on the line above and I have to CTRL+C to exit the process. All paths resolve correctly, I double checked.

When I rewrite the line using copySync syntax, I get the following error:

fse.copySync(path.join(__dirname, '..', 'book', 'templates'), path.join('.', title, 'templates')).catch(err => { console.log(err);  process.exit(0) })

Error log:

(node:27636) UnhandledPromiseRejectionWarning: RangeError: Maximum call stack size exceeded
    at getPathFromURL (internal/url.js:1395:24)
    at Object.statSync (fs.js:819:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:143:21)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/sa/Projects/ror/bubblin.io/tools/abelone/node_modules/fs-extra/lib/util/stat.js:154:10)
(node:27636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

But when I write with Promise.then() syntax it works:

fse.copy(path.join(__dirname, '..', 'book', 'templates'), path.join('.', title, 'templates')).catch(err => { console.log(err);  process.exit(0) })

The control moves to next line correctly when using then().catch() syntax… but my entire script is using async await pattern. One thing to note with all three syntax options is that the copying of directory is successful in each, it is only the stack execution that either hangs or exits with an error in the case of first two options.

Is this something others are seeing too?

Most helpful comment

Should be fixed in v8.0.1

All 5 comments

I believe this is the same as https://github.com/jprichardson/node-fs-extra/issues/678; @manidlou?

Same here with stats, until v8 :

RangeError: Maximum call stack size exceeded
    at Object.statSync (fs.js:865:18)
    at checkParentPathsSync (/Users/david/dev/formats/node_modules/fs-extra/lib/util/stat.js:143:21)
    at checkParentPathsSync (/Users/david/dev/formats/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/david/dev/formats/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/david/dev/formats/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/david/dev/formats/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/david/dev/formats/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/david/dev/formats/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/david/dev/formats/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/david/dev/formats/node_modules/fs-extra/lib/util/stat.js:154:10)

Same problem

RangeError: Maximum call stack size exceeded
    at Number (<anonymous>)
    at dateFromNumeric (internal/fs/utils.js:232:19)
    at new Stats (internal/fs/utils.js:266:16)
    at getStatsFromBinding (internal/fs/utils.js:312:10)
    at Object.statSync (fs.js:851:10)
    at checkParentPathsSync (/Users/me/project/node_modules/fs-extra/lib/util/stat.js:143:21)
    at checkParentPathsSync (/Users/me/project/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/me/project/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/me/project/node_modules/fs-extra/lib/util/stat.js:154:10)
    at checkParentPathsSync (/Users/me/project/node_modules/fs-extra/lib/util/stat.js:154:10)

Any workaround?

yeah I would say this is the same as #678 and will be fixed with #679. If #679 doesn't fix it, we will dive deeper into that! but seems like that's why this issue has been happening!

Should be fixed in v8.0.1

Was this page helpful?
0 / 5 - 0 ratings