Skip to content
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

Node fs.copyfileSync hangs when source and destination are identical #27746

Closed
fgauthie opened this issue May 17, 2019 · 2 comments · Fixed by #28449
Closed

Node fs.copyfileSync hangs when source and destination are identical #27746

fgauthie opened this issue May 17, 2019 · 2 comments · Fixed by #28449
Labels
confirmed-bug Issues with confirmed bugs. libuv Issues and PRs related to the libuv dependency or the uv binding.

Comments

@fgauthie
Copy link

fgauthie commented May 17, 2019

Unless the fs.constants.COPYFILE_EXCL flag is passed, when source and destination are the same, Node hangs forever.

const fs = require('fs'); 

fs.writeFileSync('foo', 'Hello World!');
fs.copyFileSync('foo', 'foo');

//Never reach here
console.log('Done');
@addaleax addaleax added confirmed-bug Issues with confirmed bugs. libuv Issues and PRs related to the libuv dependency or the uv binding. labels May 17, 2019
@santigimeno
Copy link
Member

I think if the proposal in libuv/libuv#2237 is implemented, this should be fixed.

@fgauthie
Copy link
Author

Thanks for quick response!

Indeed, it seems likely that this would fix the issue.

santigimeno added a commit to libuv/libuv that referenced this issue Jun 23, 2019
Specifically return success.
It fixes a tight loop on unices as `sendfile()` was returning 0 and also
makes the function behave the same both on `unix` and `windows`.

It partially implements: #2237

PR-URL: #2298
Refs: nodejs/node#27746
Reviewed-By: Jameson Nash <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
cjihrig added a commit to cjihrig/node that referenced this issue Jun 29, 2019
Notable changes:

- Support for the Haiku platform has been added.
- The maximum UV_THREADPOOL_SIZE has been increased from
  128 to 1024.
- uv_fs_copyfile() now works properly when the source and
  destination files are the same.

PR-URL: nodejs#28449
Fixes: nodejs#27746
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
targos pushed a commit that referenced this issue Jul 2, 2019
Notable changes:

- Support for the Haiku platform has been added.
- The maximum UV_THREADPOOL_SIZE has been increased from
  128 to 1024.
- uv_fs_copyfile() now works properly when the source and
  destination files are the same.

PR-URL: #28449
Fixes: #27746
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
targos pushed a commit that referenced this issue Jul 2, 2019
Notable changes:

- Support for the Haiku platform has been added.
- The maximum UV_THREADPOOL_SIZE has been increased from
  128 to 1024.
- uv_fs_copyfile() now works properly when the source and
  destination files are the same.

PR-URL: #28449
Fixes: #27746
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
BethGriggs pushed a commit to BethGriggs/node that referenced this issue Feb 26, 2020
Notable changes:

- Support for the Haiku platform has been added.
- The maximum UV_THREADPOOL_SIZE has been increased from
  128 to 1024.
- uv_fs_copyfile() now works properly when the source and
  destination files are the same.

PR-URL: nodejs#28449
Fixes: nodejs#27746
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
BethGriggs pushed a commit that referenced this issue Mar 2, 2020
Notable changes:

- Support for the Haiku platform has been added.
- The maximum UV_THREADPOOL_SIZE has been increased from
  128 to 1024.
- uv_fs_copyfile() now works properly when the source and
  destination files are the same.

PR-URL: #28449
Backport-PR-URL: #31969
Fixes: #27746
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. libuv Issues and PRs related to the libuv dependency or the uv binding.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants