isaacs / node-graceful-fs

fs with incremental backoff on EMFILE
ISC License
1.27k stars 148 forks source link

v4.2.8 and v4.2.7 break when used on node < 6 #218

Closed codeimpossible closed 2 years ago

codeimpossible commented 3 years ago

When using graceful-fs v4.2.7+ fs.readdir() throws an exception on node < 6.

TypeError: callback must be a function
[20:31:16][Step 1/1]     at makeCallback (fs.js:78:11)
[20:31:16][Step 1/1]     at fs.readdir (fs.js:847:14)
[20:31:16][Step 1/1]     at go$readdir (node_modules\graceful-fs\graceful-fs.js:201:14)
[20:31:16][Step 1/1]     at Object.readdir (node_modules\graceful-fs\graceful-fs.js:198:12)

This is due to options being passed consistently in v4.2.7+ rather than before when it was only passed if it wasn't a function. options was added as part of fs.readdir() in node 6.0.0.

See code before the change vs code after the change.

Could v4.2.7 and v4.2.8 be rolled back and shipped as breaking changes (v5.0.0) instead to prevent issues on older builds? Also, dropping node < 6 as a supported engine would be a good way to enforce any dependency on newer api signatures.

pvw87 commented 3 years ago

I am having a similar issue using node v0.12.13. "graceful-fs" is one of the dependencies of "readdirp" package and its breaking the functionality. It was working fine with 4.2.6

kguelzau commented 3 years ago

This prevents builds with good old Gitbook Legacy on Node 6.9.x. gitbook-cli downloads gitbook 2.6.9 -> fstream-ignore 1.0.2 -> fstream 1.0.12 -> graceful-fs 4.2.8 = no gitbook is created anymore. Manually changing the version to 4.2.6 solves the problem.

dcoquet-starz commented 3 years ago

Also experiencing this issue. Works as expected with v4.2.6

ZheyangSong commented 3 years ago

Run into similar issue with readdir when using module fs-extra (which internally depends on graceful-fs). As I far as I can track down the logic, the callback passed to readdir isn't called somehow.

And I can confirm that graceful-fs@4.2.6 works.

Environment: OS: macOS BigSur Node: 0.10.48

codeimpossible commented 2 years ago

@isaacs just wondering if you've had a chance to look this over?

isaacs commented 2 years ago

Wow, running node 6 on a new mac is a huge pita. 😅

I think this works now, please try with npm install isaacs/node-graceful-fs and if it fixes the issue, I'll publish to npm.