cpx icon indicating copy to clipboard operation
cpx copied to clipboard

sometimes cpx fails to copy files and directories

Open akosyakov opened this issue 7 years ago • 9 comments

sometimes chokidar should be tuned to a concrete OS to work reliable, be able to pass chokidar options will be nice

akosyakov avatar May 24 '17 07:05 akosyakov

Also migrating to the latest chokidar also would be nice

akosyakov avatar May 24 '17 07:05 akosyakov

Thank you for this issue.

Could you make a concrete proposal? I can work in this weekend.

Also migrating to the latest chokidar also would be nice

^1.6.0 looks to install the latest version: https://david-dm.org/mysticatea/cpx

mysticatea avatar May 24 '17 08:05 mysticatea

Sometimes not all files are copied for some reasons, we want to try to pass awaitWriteFinish.

akosyakov avatar May 24 '17 08:05 akosyakov

@mysticatea Maybe you can actually fix real issues:

  • cpx sometimes copy files which are not completely written yet, only partial content
  • if a glob src pattern can be matched to a folder, like src/**/*, then sometimes cpx completely misses copying subfolders

You can see more discussions on this PR: https://github.com/theia-ide/theia/pull/156

The issue seems to be related to when and how fast events are produced by chokidar.

I see that vscode buffers events from chokidar and only when 50 milliseconds passed and there were no new events from chokidar it propagates buffered to the client code: https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/services/files/node/watcher/unix/chokidarWatcherService.ts#L25. It could be that it is done to overcome issues like stated above.

Also awaitWriteFinish was not helpful to overcome it.

Right now it is a showstopper issue for us to continue using cpx.

akosyakov avatar May 30 '17 05:05 akosyakov

Thank you for the information. I'm sorry that I failed to get time in the last weekend because of my job was busy. I'll work within some days, I have 4 days' holiday since 6/1.

mysticatea avatar May 30 '17 05:05 mysticatea

I've ended up using gulp 4 instead for watching and copying. It uses https://github.com/gulpjs/glob-watcher for watching that behaves quite deterministic. And for copying one can use newer plugin to copy incrementally that boosts performance.

akosyakov avatar Jun 06 '17 05:06 akosyakov

@akosyakov, is this the reason I sometimes see files not copied, but a 0-byte "copy" created in the target directory instead?

bobbylight avatar Jan 19 '18 04:01 bobbylight

@bobbylight @mysticatea I'm noticing the same behavior. I raised a similar issue about postcss-cli (https://github.com/postcss/postcss-cli/issues/215) which was fixed by adjusting the chokidar options as mentioned. Babel has a similar fix in place at https://github.com/babel/babel/blob/ab62a9439918edf97eeea730a444a622542696ff/packages/babel-cli/src/babel/dir.js#L152-L155, so it seems to be a common workaround.

mdmoreau avatar Sep 18 '18 21:09 mdmoreau

Is this ever going to be fixed? For me it fails about 40% of the time.

Is there any replacement for this module if it is not going to be fixed?

SCLeoX avatar Nov 25 '19 20:11 SCLeoX