Skip to content

fs: ignore fstat errors on user fds in fs.readFile{Sync}

On Windows fstat cannot be called on std fds. In those cases, we already know that the fd is not for a regular file and can just use a list of buffers to store the data.

Also makes sure that we don't close fds provided by users if we cannot call fstat on them.

Fixes: https://github.com/nodejs/node/issues/19831

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Note that this does not actually fix https://github.com/nodejs/node/issues/19831#issuecomment-389573073 (on Windows calling fstat on those fds returns EISDIR..even if errors are intended, EISDIR is a rather odd error for this)

Merge request reports

Loading