Skip to content

fs.copyFile fails copying from nfs source to nfs dest file. #36439

@moqtadir

Description

@moqtadir

When copying a file from nfs mount to the same nfs mount, fs.copyFileSync fails with ENOTSUP error.
This was not replicated in Node 12.x, but is reproducible consistently in node v14.15.1

To reproduce using 2 line test file
Using node 14.15.1 on CentOS 7 X86_64
And make sure /mnt/nfs_assets/ is an nfs4 mount.

[root@local]# cat <<'EOF' > test.js
const fs = require('fs');
fs.copyFileSync('/mnt/nfs_assets/source.txt', '/mnt/nfs_assets/dest.txt');
EOF

[root@local]# cat <<'EOF' > /mnt/nfs_assets/source.txt
foorbar
EOF

[root@local]# node test.js
internal/fs/utils.js:308
    throw err;
    ^

Error: ENOTSUP: operation not supported on socket, copyfile '/mnt/nfs_assets/source.txt' -> '/mnt/nfs_assets/dest.txt'
    at Object.copyFileSync (fs.js:1991:3)
    at Object.<anonymous> (/home/user/test.js:2:4)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -95,
  syscall: 'copyfile',
  code: 'ENOTSUP',
  path: '/mnt/nfs_assets/source.txt',
  dest: '/mnt/nfs_assets/dest.txt'
}

I haven't researched this much, but the ifdef (linux) second was added recently and is now using the copyfile call but does not account for ENOTSUP being returned?

#ifdef __linux__

Relevant commit.
cf34854

Please let me know if you need any additional information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.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