-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fs.readFile of directory on IBM i returns "Unknown system error -64" instead of "EISDIR" #25433
Comments
@nodejs/platform-aix @gireeshpunathil just a check, you are in the above group? |
If the only cause of Perhaps if read() returns |
@sam-github There are various ways to get |
It should be in libuv. I suggest opening a PR there. |
@kadler Are you working on this? If not, I could revert libuv/libuv#2025 but with |
Yes, working on it, though I've been tied up with other things at the moment. |
I've opened a libuv PR here: libuv/libuv#2148 |
On IBM i PASE, EOPNOTSUPP is returned when reading a directory instead of EISDIR, like (seemingly) every other platform which doesn't support reading directories. To ensure compatibility with software expecting EISDIR, we map the EOPNOTSUPP to EISDIR when the fd passed in was a directory. This is a partial revert of 25a3894, but scoped to PASE and the fstat call is moved to the end so it's out of the fast path. Refs: nodejs/node#25433 Fixes: #2147 PR-URL: #2148 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
This was fixed in libuv 1.25.0. |
On IBM i PASE, EOPNOTSUPP is returned when reading a directory instead of EISDIR, like (seemingly) every other platform which doesn't support reading directories. To ensure compatibility with software expecting EISDIR, we map the EOPNOTSUPP to EISDIR when the fd passed in was a directory. This is a partial revert of 25a3894, but scoped to PASE and the fstat call is moved to the end so it's out of the fast path. Refs: nodejs/node#25433 Fixes: libuv#2147 PR-URL: libuv#2148 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
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 isEOPNOTSUPP
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
orENOTASHIM
: https://github.com/npm/gentle-fs/blob/latest/lib/rm.js#L245-L248So 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 callingreadCmdShim
, 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 theEISDIR
behavior and convert theEOPNOTSUPP
on IBM i toEISDIR
, but is then the question is whether that should happen in libuv or in Node.The text was updated successfully, but these errors were encountered: