node-dependency-tree icon indicating copy to clipboard operation
node-dependency-tree copied to clipboard

Fix tests on Node.js 20

Open XhmikosR opened this issue 2 years ago • 5 comments

Something changed in Node.js 20 and tests fail on main since a few months now.

If someone figures out why, please make a PR and CC me.

XhmikosR avatar Nov 22 '23 08:11 XhmikosR

I have the same problem. @XhmikosR which version of node it started?

Seems like it works with 20.4.0 but fail on 20.5.0

GiladShoham avatar Nov 29 '23 19:11 GiladShoham

Maybe it's related to this change in 20.5.0 [986b46a567] - fs: add a fast-path for readFileSync utf-8 (Yagiz Nizipli) https://github.com/nodejs/node/pull/48658

GiladShoham avatar Nov 29 '23 19:11 GiladShoham

another relevant reference is here - https://github.com/kubernetes-client/javascript/pull/1202 and also this one - https://github.com/tschaub/mock-fs/issues/377

GiladShoham avatar Nov 29 '23 19:11 GiladShoham

@GiladShoham yeah you are probably right. Unsure how to make tests pass again on Node.js 20. If you have any suggestions feel free to make a PR and CC me.

EDIT: I just looked at your linked PRs. It seems it's just a matter of calling toString('utf-8'). Anyway, feel free to make a PR.

XhmikosR avatar Apr 04 '24 18:04 XhmikosR

I pushed a branch with debug enabled on CI and the issue seems to be with fs.existsSync:

  • Node.js 18: https://github.com/dependents/node-dependency-tree/actions/runs/8565544868/job/23473747457
  • Node.js 20: https://github.com/dependents/node-dependency-tree/actions/runs/8565544868/job/23473747584

Unsure how to proceed...

We are also hitting this in other repos like node-stylus-lookup:

  • https://github.com/dependents/node-stylus-lookup/actions/runs/8565474632/job/23473580973
  • https://github.com/dependents/node-stylus-lookup/actions/runs/8565474632/job/23473581057

EDIT: looks like it's a mock-fs issue? https://github.com/tschaub/mock-fs/issues/377

XhmikosR avatar Apr 05 '24 05:04 XhmikosR