Closed Xeio closed 9 years ago
That's a bad solution as the file might be busy for a long time or infinity.
Better to just use https://github.com/isaacs/node-graceful-fs for fs
operations.
I tried using graceful-fs but now I just see EPERM errors instead of EBUSY. Not sure if I'm misusing the library or if there's some additional settings that are needed for that library to wrap the errors.
I could clean up the file a little more deterministically, by doing it after the PhantomJS process is terminated (since that's what's keeping the file open), but I'm not sure how to do this without doing at least one wait period.
Maybe just only retry once? I never saw it take more than one wait period in practice but that would be machine specific.
I'm seeing an error sometimes when I run qunit tests with Grunt on Windows. Error message: "Fatal error: EBUSY, resource busy or locked" for the temp file used by PhantomJS.
This pull request has a fix for the issue, basically just retrying the unlink if it fails due to an EBUSY error.