isaacs / node-graceful-fs

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

cb is not a function #227

Closed vikas-shinde closed 2 years ago

vikas-shinde commented 2 years ago

Hi we are getting this error cb is not a function

internal/fs/streams.js:254 cb(er || err); ^

TypeError: cb is not a function at internal/fs/streams.js:254:5 at D:\MIndN\Bablr\Workspace\Final Testing\babygq\api\node_modules\graceful-fs\graceful-fs.js:61:14 at FSReqCallback.oncomplete (fs.js:171:23)

we are using node version v14.15.0 can any one help us to resolve this problem.

kylewintaur commented 2 years ago

Same issue here, this blog post fixed it for me: https://flaviocopes.com/cb-apply-not-a-function/

isaacs commented 2 years ago

This was fixed in graceful-fs v4.2.9. Please update.

vikas-shinde commented 2 years ago

We are using let us version v4.2.9 but still giving error cb is not a function

vikas-shinde commented 2 years ago

We manage to fixes this problem. we just modify the file graceful-fs.js at location node_modules\graceful-fs\graceful-fs.js

for aver environment it gives error at line 61:14 that is this line

if (typeof cb === 'function') cb.apply(this, arguments)

we just add this line in to try and catch block and its work for me

isaacs commented 2 years ago

Yeah, cb is definitely a function there.

To debug this, I'll need at minimum the actual stack trace (with line number) and the output of npm ls graceful-fs (to see the version you're using). The line you're showing, in the latest released version, is definitely ensuring that cb is a function prior to calling it. So it's not that.