Skip to content
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

fix(preprocessor): retry if fs.readFile fails #2714

Merged

Conversation

ywongau
Copy link
Contributor

@ywongau ywongau commented May 17, 2017

When saving a file in IDEs like Visual Studio, Atom, a dozen operations including read/write/delete/rename are performed on the file. When aggressive antivirus like McAfee is running it could make it even worse, there are nearly 50% chance karma will crash because the file is locked

There were multiple issues raised because of this

#1397
#1213
#959

The solution is retry reading file if fs.readFile fails and throw after 3 failed retries

@@ -121,7 +130,8 @@ var createPreprocessor = function (config, basePath, injector) {

nextPreprocessor(null, thisFileIsBinary ? buffer : buffer.toString())
})
})
}
return fs.readFile(file.originalPath, handleFile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should call handleFile probably?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs.readFile is the correct call as handleFile was the original anonymous callback at line 79

I've renamed handleFile to readFileCallback to make it clearer

@dignifiedquire dignifiedquire merged commit 545dc05 into karma-runner:master Jun 26, 2017
@dignifiedquire
Copy link
Member

Thank you :octocat:

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

Successfully merging this pull request may close these issues.

2 participants