-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
Fix "illegal operation on a directory, realpath" on RAM Disk #229
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we need this complexity, let's please add a regression test.
fs.realpath.native(path, function (realpathErr, realPath) { | ||
if (realpathErr && realpathErr.errno === -4068) { | ||
fs.realpath(path, callback); | ||
} else { | ||
return callback(realpathErr, realPath); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this means we pay a performance cost every time. is this necessary, or on a given system where it fails, will it always fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is designated for the postcss-import
on RAM Disk. This means the I/O speed is significantly improved. The production build of my Angular project takes 60-120 secs with fs.realpath.native()
on my 2TB Seagate FireCuda SSHD but it only takes ~60 secs on RAM Disk mounted by imDisk with fs.realpath()
(where fs.realpath.native()
is illegal operation). So in general, no performance costs are paid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how that's possible - this is always calling realpath.native, and when it errors, is adding the cost of calling realpath.
(to be clear, I have no idea what imDisk is, and the last time I heard anything about RAM Disks was in the late 1990s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imDisk is a software to create a virtual disk using RAM on Windows: https://imdisk.en.lo4d.com/windows
The cost of calling is the trade-off for I/O speed and it only adding the call on illegal operation error.
You can clone this repository using Windows on both RAM Disk created by imDisk and your HDD/SSHD/SSD https://github.com/scttcper/ngx-toastr. After the clone, run npm i && npm start
. On RAM Disk, the server will fail and you will get
The cause is from postcss-import
using this repository to resolve the imported files from node_modules in src/style.scss. So if you alter ./node_modules/resolve/lib/async.js, the error is gone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned about:
- adding a fix without a regression test, because there's no protection from breaking it again
- adding a complicated fix that might slow down the majority case to service a very niche edge case
I wonder if node can do something to improve the native realpath. The promise api uses the native implementation under the hood (https://nodejs.org/api/fs.html#fs_fspromises_realpath_path_options), so it'll probably become more prevalent |
@SimenB promise APIs don't do the trick, EISDIR still occurred |
@duykhang53 that makes sense - it's the same API. My point was that it shouldn't be up to consumers to deal with these issues, it should be fixed upstream in Node itself. |
This issue occurred since node v6 and now it's v14. I think it's better to apply a fallback rather than wait for nodejs to fix it. Cost of calling just slightly affected the performance but that would be better to make the code run instead of throwing errors. |
@duykhang53 the last comment in that issue, nodejs/node#6861 (comment), suggests that the proper solution is to abandom imdisk in favor of |
you can use osfmount and mount as physical drive and it works out of the box. |
The native method of
fs.realpath()
cause error on RAM Disk created by imDisk.Angular developers might get this error when running
ng s
on RAM Disk when they using scss in their projectFrom tracing in postcss-import, I got EISDIR: illegal operation on a directory, realpath 'R:\angular-project'.
For the fix,
fs.realpath.native()
will fallback tofs.realpath()
if errno is illegal operation(-4068).