[Bug]: Node.js fs.readdir new param recursive caused bug #41549
Labels
27-x-y
28-x-y
29-x-y
bug 🪲
component/node-integration
status/confirmed
A maintainer reproduced the bug or agreed with the feature
Preflight Checklist
Electron Version
27.0.4
What operating system are you using?
macOS
Operating System Version
macOS Sonoma 14.2.1
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
When I use
fs/promises.readdir
with paramswithFileTypes
andrecursive
, expect get real list of directory.And the same is:
Also is
readdirSync
:Actual Behavior
The electron version
27.0.4
get the list length is2
Testcase Gist URL
No response
Additional Information
I have found the cause of the issue. It is a bug starting from Node.js
v18.17.0
, which was only fixed inv18.19.0
. Since Electron started usingNode.js v20
in versionv29
, the earlier versions usingv18.17.1
all had issues.Furthermore, as Node.js
fs.readdir
already supports the recursive parameter, it is not supported inlib/node/asar-fs-wrapper.ts
. Therefore, there will be a bug when packaging if it is an internal file (whenisAsar
is true).The cause of this issue lies in a bug in
fs.readdir
, but in fact, the originalfs.promises.readdir
is not problematic. It is a separate implementation fromfs.readdir
, so the bug occurred in the above code due to the usage offs.promises.readdir = util.promisify(fs.readdir);
.Moreover, the native
fs.readdir
may have performance issues when used recursively, as mentioned here. Please be aware of this if you intend to support it.The text was updated successfully, but these errors were encountered: