Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Race condition under Windows #8

Closed
Cito opened this issue Nov 17, 2017 · 0 comments
Closed

Race condition under Windows #8

Cito opened this issue Nov 17, 2017 · 0 comments

Comments

@Cito
Copy link

Cito commented Nov 17, 2017

When running the following under Windows, I sometimes get an EPERM error:

var fs = require("fs")
var fsvacuum = require("fs-vacuum")

var options = {
  base  : ".",
  purge : true
};

function vacuum(path) {
    fsvacuum(path, options, function (error) {
        if (error) console.error("Cannot remove", path, error)
    })
}

fs.mkdirSync("foo")
fs.mkdirSync("foo/bar")
fs.mkdirSync("foo/bar/bax")
fs.mkdirSync("foo/bar/bay")
fs.mkdirSync("foo/bar/baz")

vacuum("foo/bar/bax")
vacuum("foo/bar/bay")
vacuum("foo/bar/baz")
vacuum("foo")

Apparently this can happen under Windows when concurrent lstat, readdir and rmdir operations are blocking each other - I noticed that the error can occur in all of these calls inside the next() function of vacuum.

The rimraf package contains an internal function fixWinEPERM that addresses this issue. Maybe something similar needs to be added to vacuum as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants