nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
105.65k stars 28.65k forks source link

node 12.18.3 fails with TypeError: cb.apply is not a function in graceful-fs #34529

Closed marcelgsteiger closed 4 years ago

marcelgsteiger commented 4 years ago

After upgrading my Raspberry Pi 4 today, my nodered app stopped operating. I get the error

TypeError: cb.apply is not a function at ~/.node-red/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18 at FSReqCallback.oncomplete (fs.js:169:5) nodered.service: Main process exited, code=exited, status=1/FAILURE nodered.service: Failed with result 'exit-code'.

I then went back to 12.18.0 - which operates flawlessly, then to 12.18.2 with npm 6.14.5, this also works as expected.

npm list /root ├─┬ @iekedemus/vulgar-fraction@1.0.0 │ └── greatest-common-divisor@1.0.0 ├── graceful-fs@4.2.4 └── jsonata@1.8.3

Steps that caused the problem:

apt upgrade / apt update / npm update to current versions

Remarks:

I think this is a very recent issue but I do not know if I could reproduce it just by updating nodered. 25 packages were updated, including kernel and system firmware.

Regards Marcel

addaleax commented 4 years ago

See https://github.com/nodejs/help/issues/2871, https://github.com/nodejs/help/issues/2874, https://github.com/nodejs/node/issues/34162, etc. – you’re using an outdated version of npm. Updating the npm in your source tree (or updating the graceful-fs within it) should help here.

marcelgsteiger commented 3 years ago

Thank you for your quick response. I've been using npm 6.14.5 . Upgrading to 6.14.7 (npm@latest) does not help here. The error persists with node 12.18.3 and vanishes as soon as I go back to 12.18.2 . graceful-fs is already on the latest version 4.2.4. So I believe one of the numerous changes between 12.18.2 and 12.18.3 causes the issue on my platform. I also tried npm 6.14.6 (mentioned as dependency in node 12.18.3) but I get the same error. Could this be specific to my platform or kernel version, perhaps a timing issue? Pls let me know if I can provide some additional information for reproducing/debugging. Regards Marcel

iamstarkov commented 3 years ago

I have the same problem

iamstarkov commented 3 years ago

@addaleax I know you may be hesitant to reopen this bug due to prior similar issues with npm and graceful-fs and I've seen them and encountered those issues myself, so I have reasons to believe its a new bug. Please hear me out if not for me but for hundreds of others who experiences the same issue, but do not report.

I've faced the same bug and updated to latest npm and pinned graceful-fs to the latest version in the yarn.lock and it didnt help. The only fix which worked is to downgrade to node 12.18.2. I'm together with @milprog and think that its a new bug and it is something else.

Project I struggled with is my company ui kit https://github.com/nordnet/ui/ with semantic-release enabled and as soon 12.8.3 was released and picked by travis release process broke.

Here is the verifiable points concluded from my investigation of broken releases of our ui kit:

addaleax commented 3 years ago

@iamstarkov The problem is the semantic-release@16.0.0-beta.18 (hardcoded in your package.json, no semver range) → @semantic-release/npm@^5.2.0-beta.5npm@6.5.0 (also hardcoded, no semver range) dependency chain. Simply upgrading your dependencies should be enough. You may not want to rely on beta versions of tools anyway.

iamstarkov commented 3 years ago

I will definitely upgrade away from beta in the future.

Can you elaborate a bit more why this dependency chain is a problem? I don't understand why it stopped working in latest patch release of node. It's a patch release not a minor or a major one.

addaleax commented 3 years ago

@iamstarkov Right, but graceful-fs (which is not just a dependency of npm, it’s actually shipped as part of the npm package) depends on Node.js internals in a way that does not follow semver. In particular, in this case, we started using a custom option for a file system operation inside of Node.js itself, and the monkey-patched fs module from graceful-fs did not recognize that option in earlier versions.

prionkor commented 3 years ago

Just a FYI, I am having similar problem with node 12 as well as 14 alpine docker containers.