-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Unknown error when copying files > 2GB using fs #30085
Comments
I am not able to reproduce the issue on Windows; maybe this is specific to macOS or AppleFS. What happens if you try to copy the file using Also, does this issue happen only with const fs = require("fs");
fs.copyFileSync("./2GB.bin", "./2GB-copySync.bin");
fs.copyFile(
"./2GB.bin",
"./2GB-copyASync.bin",
console.log
);
fs.promises
.copyFile("./2GB.bin", "./2GB-copyPromise.bin")
.then(console.log, console.error); |
This sounds like a bug in libuv. Quick experiment... can you try with Node 10.0.0. That version still had a macOS specific implementation, so I'd be curious to see if that version works. |
Good test, yes using v10.0.0 works without any problems. So Node moved to libuv after 10.0.0? I wonder why it's fine on my laptop.
|
Not quite. Node has been using libuv for years. The underlying implementation of
My first guess is that the two machines use a different number of bits to represent the file size, or something, but it's just a guess. |
Can I run any tests to verify this? I understand this problem might be hard to reproduce, if I can help in any way please let me know. Should I post this bug on the libuv repo also? |
If you're comfortable with recompiling Node from source, I think it would be good to log the value here. That would tell us how many bytes libuv is trying to copy. If things were working properly, it should be the same as your file's size. |
I put in a It does seem like it is the correct output, as that number is the exact bytes of the 2GB.bin
|
I think the next thing to check would be the values of Out of curiosity - you mentioned that the code is working fine on your laptop. Is your laptop also running Catalina? |
errno 38 means ENOSYS, Function not implemented correct? Yes what's strange is my laptop has the exact same software environment. At this point I'm thinking it could be hardware related perhaps, but all other functions seem to work fine. I tried copying the same file using Ruby and it worked without issues. |
I believe 38 is |
Yes you're right, the error code is indeed
The last output before the Node error output in the console is:
Is it normal for nwritten to not be incremented? |
When |
Thanks for the help and quick response. I commented out that code block and checked the checksum of the original and destination files and they do seem to match:
The |
The Unix/macOS uv__fs_copyfile() implementation falls back to using uv_fs_sendfile(). This commit refactors the error handling to use the sendfile() req's result field, which is an ssize_t instead of using the return value, which is an int. The int value was coming back as a negative number for some large files. Refs: nodejs/node#30085
Proposed fix in libuv/libuv#2533. |
Thanks for putting this fix in, I compiled using your commit and seems to be working. I will use a local version until it is merged. |
The Unix/macOS uv__fs_copyfile() implementation falls back to using uv_fs_sendfile(). This commit refactors the error handling to use the sendfile() req's result field, which is an ssize_t instead of using the return value, which is an int. The int value was coming back as a negative number for some large files. Refs: nodejs/node#30085
The Unix/macOS uv__fs_copyfile() implementation falls back to using uv_fs_sendfile(). This commit refactors the error handling to use the sendfile() req's result field, which is an ssize_t instead of using the return value, which is an int. The int value was coming back as a negative number for some large files. Refs: nodejs/node#30085 PR-URL: libuv#2533 Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Saúl Ibarra Corretgé <[email protected]> Reviewed-By: Richard Lau <[email protected]>
I had the same problem on Mojave iMac Pro (2018) nodejs 10.16. I used the proposed by @cjihrig 's patch and it works for now (nodejs 10.17.1-pre). |
Notable changes: - Fix handling of large files in `uv_fs_copyfile()`. Fixes: nodejs#30085 - Fix Android build errors. - uv_sleep() has been added. - uv_interface_addresses() IPv6 netmask support has been fixed. Fixes: nodejs#30504 - uv_fs_mkstemp() has been added.
Notable changes: - Fix handling of large files in uv_fs_copyfile(). Fixes: #30085 - Fix Android build errors. - uv_sleep() has been added. - uv_interface_addresses() IPv6 netmask support has been fixed. Fixes: #30504 - uv_fs_mkstemp() has been added. PR-URL: #30783 Fixes: #30085 Fixes: #30504 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Notable changes: - Fix handling of large files in uv_fs_copyfile(). Fixes: #30085 - Fix Android build errors. - uv_sleep() has been added. - uv_interface_addresses() IPv6 netmask support has been fixed. Fixes: #30504 - uv_fs_mkstemp() has been added. PR-URL: #30783 Fixes: #30085 Fixes: #30504 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Notable changes: - Fix handling of large files in uv_fs_copyfile(). Fixes: #30085 - Fix Android build errors. - uv_sleep() has been added. - uv_interface_addresses() IPv6 netmask support has been fixed. Fixes: #30504 - uv_fs_mkstemp() has been added. PR-URL: #30783 Fixes: #30085 Fixes: #30504 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Notable changes: - Fix handling of large files in uv_fs_copyfile(). Fixes: nodejs#30085 - Fix Android build errors. - uv_sleep() has been added. - uv_interface_addresses() IPv6 netmask support has been fixed. Fixes: nodejs#30504 - uv_fs_mkstemp() has been added. PR-URL: nodejs#30783 Fixes: nodejs#30085 Fixes: nodejs#30504 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Notable changes: - Fix handling of large files in uv_fs_copyfile(). Fixes: #30085 - Fix Android build errors. - uv_sleep() has been added. - uv_interface_addresses() IPv6 netmask support has been fixed. Fixes: #30504 - uv_fs_mkstemp() has been added. PR-URL: #30783 Backport-PR-URL: #31969 Fixes: #30085 Fixes: #30504 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Sorry new to building apps with Node.js and electron. How do I go about fixing this? I've updated to the latest version of node and the problem persists. |
[2]
|
I'm having a very strange error on my Mac mini when using fs (both sync and async) copyFile to copy a file larger than 2GB. What's weird is on my MacBook Air with the same software setup there isn't any issues.
I created 2 files for testing using
mkfile -n 1999m
andmkfile -n 2g
, then tried to copy them using node. the 1.999GB file worked fine and the 2GB file failed with unknown error. So there is a clear limit of 2GB here for some reason.If this isn't a bug, how would one start to diagnose this further? The vague error certainly doesn't help. I've ruled out permission and drive space problems already, even reinstalled macOS from scratch but didn't help.
More info on Stackoverflow:
https://stackoverflow.com/questions/58500025/node-unknown-system-error-when-copying-large-files-over-2gb
The text was updated successfully, but these errors were encountered: