forked from finboxio/mockgo
-
Notifications
You must be signed in to change notification settings - Fork 4
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
EBUSY: resource busy or locked when stop server in tests #4
Comments
I run into the issue when I run multiple tests in serie. The data directories won't be deleted. |
Having this one also; it's a big problem when using it with Wallaby.js. It created 1500 |
Not really a solution; but I'm using a custom stop method to cleanup sibling directories that's been left earlier. This to reduce the noise a bit. const getDataDirs = root => fs.readdirSync(root)
.filter(f => fs.statSync(path.join(root, f)).isDirectory())
.filter(d => /.data-[a-z0-9]{7}/.test(d))
.map(d => path.join(root, d));
const tryDelete = dir => {
try { rimraf.sync(dir) }
catch (e) { }
};
async function stopMongo(server) {
try {
await server.stop();
}
catch (ex) {
if (ex.code !== 'EBUSY' || ex.syscall !== 'unlink') {
throw ex;
}
}
finally {
const root = server.databasePath.substr(0, server.databasePath.length - 13);
getDataDirs(root).forEach(tryDelete);
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: