question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: `readdir` implementations don't accept `null` as second argument

See original GitHub issue

Self-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:closed
  • Created 2 years ago
  • Reactions:23
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
merceyzcommented, Aug 10, 2021

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

yarn set version berry && yarn set version canary
3reactions
merceyzcommented, Aug 10, 2021

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found