fs: readDir {withFileTypes: true} could call callback more than once
- Version: 10.10.0
- Platform:
- Subsystem: fs
While looking through the code of readDir's new option withFileTypes I noticed that getDirents unconditionally calls the callback in case of an error:
| if (err) { | |
| callback(err); | |
| return; | |
| } |
If more than one file is of type UV_DIRENT_UNKNOWN and fs.stat returns with an error for more than one of these files, the callback will be called more than once. That could lead to unexpected behavior for API users.
I don't know if that needs to be fixed as the scenario seems very unlikely, but I thought I should at least report it.