gruntjs / grunt-lib-phantomjs

Grunt and PhantomJS, sitting in a tree.
http://gruntjs.com/
MIT License
93 stars 63 forks source link

Fix EBUSY error on Windows when deleting temp file #85

Closed Xeio closed 8 years ago

Xeio commented 9 years ago

Closed the previous request, this is an alternative changeset.

This should behave a little more deterministically as the file gets deleted after the process using it is terminated. Additional upside to this is that PhantomJS won't be able to write to the temp file after we delete it.

I was unable to get graceful-fs to work without a similar retry mechanism, though I did see EPERM errors instead of EBUSY. Maybe there's some additional configuration needed that I missed but I couldn't find it.

Possibly the retry timeout should be configurable, but the OS usually unlocks the file almost immediately once the process is terminated. It was working for me even with a setTimout of zero, so the 100 is mostly arbitrary.

Louisblack commented 9 years ago

I've just tested this change against a project with this issue when using grunt-contrib-jasmine to run tests. On my Windows 7 machine it looks like it has fixed the problem.

Arkni commented 8 years ago

I think a best approach would be using rimraf to remove the temp file. Would you mind updating this PR to use rimraf instead, of course if you have the time to.

Xeio commented 8 years ago

Updated PR.

Arkni commented 8 years ago

Merged. Thanks :)