fs-extra version: 8.0.1Hey, 👋
After updating fs-extra from v7 to v8, jest tests started to give error for copy function:
TypeError: cb.apply is not a function

Here is same reproduction repo with failing test. The repo has only two commits, one is with v7 and no error, second is just an update to v8 and with error.
I saw this from travis, which gave error for node v10 and v12, but not for v8. Here is travis log. Rollback to v7 removes error.
Any idea why this is happening? 🤔
Also getting this error. I haven't bothered to hunt down which function is causing it but in my case I'm not using copy().
hmm..! That's so weird! That error basically comes from graceful-fs that we use as a dependency. But we disabled that and used native fs in fs-extra v8.0.1 to use fs.stat() with bigint option.
wondering if we need to disable that in the fs/index.js until they update their code!
Would be useful to have a non-jest example so we could get the full stack trace.
@RyanZim I tried same example without jest (same node version 12.1.0) and it didn't give me error.
const fs = require('fs-extra')
async function run() {
const src = 'tests/fixtures/src/asset.js'
const dest = 'tests/fixtures/dist/asset.js'
await fs.copy(src, dest)
}
run()
My best attempt to get error:
/Users/shcherbin/Sites/test/experiments/fs-extra-8-jest/node_modules/graceful-fs/polyfills.js:285
if (cb) cb.apply(this, arguments)
^
TypeError: cb.apply is not a function
at /Users/shcherbin/Sites/test/experiments/fs-extra-8-jest/node_modules/graceful-fs/polyfills.js:285:20
at FSReqCallback.oncomplete (fs.js:167:5)
Jest globally monkey-patches the fs module itself: https://github.com/facebook/jest/blob/bcc2b103e14912cff566cbacb0c2c3871ecb0994/packages/jest-runtime/src/cli/index.ts#L26
See https://github.com/isaacs/node-graceful-fs#global-patching for details about this.
IDK how best to work with this. Should fs-extra try to detect global monkey patching and run without bigint?
The root problem is that graceful-fs is broken and needs updates. Not sure how to get action there.
Yeah exactly! If graceful-fs was updated we didn't go through all of this hassle!
Anybody opened a bug/issue report on this one? Seems like more and more projects are crashing. Jest is used prettify massively right now.
The root issue is https://github.com/isaacs/node-graceful-fs/issues/158; if we could get action there, we'd be good.
graceful-fs issue is fixed, I'm thinking this issue should be fixed by reinstalling/regenerating the lockfiles to get the latest graceful-fs. Let me know if it's not.
Hm, I still seem to see the error with 8.1.0. I used yarn ls to double check, it's pulling 4.2.0 through but it still throws this error when using fs.copy() in a Jest test.
TypeError: cb.apply is not a function
at ../../../node_modules/graceful-fs/polyfills.js:285:20
What version of graceful-fs is jest pulling in?
Per an npm ls, it's 4.2.0.
$ npm ls | grep graceful-fs
[email protected]
I'd like to see the output of npm ls graceful-fs.
Just checked, the issue is fixed for me when using graceful-fs 4.2.0.
I'm going to chalk it up to some problem in our project, I also can't
reproduce with a fresh project.
On Mon, Jul 1, 2019, 1:33 PM Vlad Shcherbin notifications@github.com
wrote:
Just checked, the issue is fixed for me when using graceful-fs 4.2.0.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/jprichardson/node-fs-extra/issues/687?email_source=notifications&email_token=AABYNXOLXRLAHK3IDO4BDALP5I5WZA5CNFSM4HM62GN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY62NDI#issuecomment-507356813,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABYNXIOW7TE3T6U4ZIA57DP5I5WZANCNFSM4HM62GNQ
.
@fastfrwrd Try doing a clean install/regenerating the lockfile.
Yep, adding "graceful-fs": "4.2.2" library helped.
Most helpful comment
The root problem is that graceful-fs is broken and needs updates. Not sure how to get action there.