GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs.readFile of directory on IBM i returns "Unknown system error -64" instead of "EISDIR" · Issue #25433 · nodejs/node

fs.readFile of directory on IBM i returns "Unknown system error -64" instead of "EISDIR" #25433

New issue
Copy link
New issue
Copy link
Closed
Closed
fs.readFile of directory on IBM i returns "Unknown system error -64" instead of "EISDIR"#25433
Copy link
Labels
aixIssues and PRs related to the AIX platform.fsIssues and PRs related to file-system APIs and the fs module.libuvIssues and PRs related to the libuv dependency or the uv binding.

Description

@kadler
kadler
opened on Jan 10, 2019
Issue body actions
  • Version: v10.15.0
  • Platform: OS400 wernstrom 2 7 0010000ACBAA Os
  • Subsystem: fs

Since upgrade of libuv to 1.23.2 in #23336, fs.readFile on a directory on the IBM i platform returns "Unknown system error -64" instead of EISDIR. (64 is EOPNOTSUPP on IBM i/PASE). Reproducing the problem is really easy:

node -e "try { require('fs').readFileSync('.') } catch(err) { console.log(err.code) }"

On Linux and macOS, this returns EISDIR, while on IBM i this now returns "Unknown system error -64".

This was changed in libuv/libuv#2025 to allow AIX to read a directory, since it's supported there (as in many BSDs and other OSes) and remove the performance penalty of doing a stat call for each read. Since the PASE environment where Node.js runs on IBM i is an AIX-like environment, this affected our platform as well, but unlike AIX, PASE does not support reading from directories.

The net result of this, is that global npm install are broken, due to gentle-fs assuming that reading from a directory will return EISDIR or ENOTASHIM: https://github.com/npm/gentle-fs/blob/latest/lib/rm.js#L245-L248

So the question is what should happen here? I think at a minimum, err.code should be "EOPNOTSUPP" instead of "Unknown system error -64", but that still wouldn't actually fix the gentle-fs issue. libuv was deliberately changed due to the performance of the stat on each read, while gentle-fs has already done a stat and didn't bother to check if it was a directory first. gentle-fs could add a stat.isDirectory() check prior to calling readCmdShim, but I don't know enough about Windows to know if a cmd shim can be a directory. The other option is to standardize on the EISDIR behavior and convert the EOPNOTSUPP on IBM i to EISDIR, but is then the question is whether that should happen in libuv or in Node.

Activity

  1. sam-github commented on Jan 10, 2019

    @sam-github
    sam-github
    on Jan 10, 2019
    Contributor
    More actions

    @nodejs/platform-aix

    @gireeshpunathil just a check, you are in the above group?

    Reacted by Gireesh Punathil
  2. sam-github commented on Jan 10, 2019

    @sam-github
    sam-github
    on Jan 10, 2019
    Contributor
    More actions

    If the only cause of EOPNOTSUPP is that the fd refers to a directory, mapping it to EISDIR is obvious, but what if the fd is something else other than a directory that does not support read()? In this case, EISDIR would be wrong.

    Perhaps if read() returns EOPNOTSUPP, it can fallback to the fstat() and return EISDIR if it was a dir, and just pass back ENOTSUPP otherwise? This would move the usually unnecessary fstat from the normal code path, to the failure path.

  3. kadler commented on Jan 10, 2019

    @kadler
    kadler
    on Jan 10, 2019
    Author
    More actions

    @sam-github There are various ways to get EOPNOTSUPP, not just for a attempting to read a directory so a simple mapping is not sufficient. The fallback to the fstat() as you proposed was what I was thinking as well, I just don't know if it's more appropriate to put that in Node or libuv.

  4. sam-github commented on Jan 10, 2019

    @sam-github
    sam-github
    on Jan 10, 2019
    Contributor
    More actions

    It should be in libuv. I suggest opening a PR there.

  5. ChALkeR
    added
    fsIssues and PRs related to file-system APIs and the fs module.
    aixIssues and PRs related to the AIX platform.
    on Jan 13, 2019
  6. bnoordhuis commented on Jan 15, 2019

    @bnoordhuis
    bnoordhuis
    on Jan 15, 2019
    Member
    More actions

    @kadler Are you working on this? If not, I could revert libuv/libuv#2025 but with s/_AIX/__PASE__/.

  7. bnoordhuis
    added
    libuvIssues and PRs related to the libuv dependency or the uv binding.
    on Jan 15, 2019
  8. kadler commented on Jan 15, 2019

    @kadler
    kadler
    on Jan 15, 2019
    Author
    More actions

    Yes, working on it, though I've been tied up with other things at the moment.

  9. kadler commented on Jan 15, 2019

    @kadler
    kadler
    on Jan 15, 2019
    Author
    More actions

    I've opened a libuv PR here: libuv/libuv#2148

  10. cjihrig
    added a commit that references this issue on Jan 17, 2019

    ibmi: return EISDIR on read from directory fd

    91ca678
  11. richardlau commented on Mar 28, 2019

    @richardlau
    richardlau
    on Mar 28, 2019
    Member
    More actions

    This was fixed in libuv 1.25.0.

  12. richardlau
    closed this as completedon Mar 28, 2019
  13. njlr
    added a commit that references this issue on Apr 5, 2019

    ibmi: return EISDIR on read from directory fd

    d2b4400
  14. liujinye-sys
    added a commit that references this issue on Jul 23, 2025

    ibmi: return EISDIR on read from directory fd

    cd35413
  15. liujinye-sys
    added a commit that references this issue on Dec 16, 2025

    ibmi: return EISDIR on read from directory fd

    6670762
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    aixIssues and PRs related to the AIX platform.fsIssues and PRs related to file-system APIs and the fs module.libuvIssues and PRs related to the libuv dependency or the uv binding.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.