[Bug]: `readdir` implementations don't accept `null` as second argument
See original GitHub issueSelf-service
- I’d be willing to implement a fix
Describe the bug
The readdir implementations in @yarnpkg/fslib don’t accept null as the second argument (which is supported by Node) and throw a cryptic:
TypeError: Cannot destructure property 'withFileTypes' of '(intermediate value)(intermediate value)(intermediate value)' as it is null.
To reproduce
await packageJsonAndInstall({});
await expect(
yarn(`node`, `-e`, `require('fs').readdirSync('.', null)`)
).resolves.toBeTruthy();
Environment
System:
OS: Linux 5.13 Arch Linux
CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
Binaries:
Node: 16.0.0 - /tmp/xfs-62396191/node
Yarn: 3.0.1-rc.1.dev - /tmp/xfs-62396191/yarn
npm: 7.10.0 - ~/.nvm/versions/node/v16.0.0/bin/npm
Additional context
There are likely other methods inside @yarnpkg/fslib that should accept null but don’t.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:23
- Comments:9 (3 by maintainers)
Top Results From Across the Web
9819 – readdir segmentation faults when passed NULL
readdir from dirent.h produces a segmentation fault if passed a NULL value, which can easily happen if the result of opendir is not...
Read more >Reading/Closing Directory (The GNU C Library)
If there are no more entries in the directory or an error is detected, readdir returns a null pointer. The following errno error...
Read more >Node.js fs.readdir recursive directory search - Stack Overflow
Beware, the "parallel loop" answer from chjj above has a bug in cases when an empty folder is walked. The fix is: var...
Read more >io/fs - Go Packages
The second call is after a failed ReadDir and reports the error from ReadDir. (If ReadDir succeeds, there is no second call.) The...
Read more >CS135 FUSE Documentation
In many FUSE implementations, the file handle is actually a pointer to a ... Set flag_nullpath_ok nonzero if your code can accept a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I just triggered a release (https://github.com/yarnpkg/berry/actions/runs/1116604206) so it should be ready in about 15 minutes, then you can run the following command to get the fix
That’s a known issue with the publish to the registry, the release itself was successful so the command in https://github.com/yarnpkg/berry/issues/3234#issuecomment-895991184 is still the solution