-
Notifications
You must be signed in to change notification settings - Fork 220
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
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. #422
Comments
The code to wait for the file is already present in the catch handler. Easiest to just expand on that: try {
const fileContents = middleware.fileSystem.readFileSync(path.join(os.tmpdir(), '_karma_webpack_', this.outputs.get(file)));
callback(null, fileContents);
} catch (e) {
// If this is an error from `readFileSync` method, wait for the next tick.
// Credit #69 @mewdriller
if (e.code === 'ENOENT' || !this.outputs.get(file)) {
// eslint-disable-line quotes
this.waiting = [process.nextTick.bind(process, this.readFile.bind(this, file, callback))]; // throw otherwise
} else {
callback(e);
}
} |
Any solution for this? I'm stuck with this issue and I cannot run tests :( |
Here is the worst monkey patch ever const karmaWebpack = require('karma-webpack')
const original = karmaWebpack.webpackPlugin[1].prototype.readFile
karmaWebpack.webpackPlugin[1].prototype.readFile = function (file, callback) {
let cb = function () {
if (arguments[0] && arguments[0].code === 'ERR_INVALID_ARG_TYPE') {
console.log('errors!!!!! waiting')
this.waiting = [process.nextTick.bind(process, this.readFile.bind(this, file, callback))]; // throw otherwise
}else{
return callback(...arguments)
}
}.bind(this)
original.call(this, file, cb)
} |
Is there any chance of having this fixed soon? We're running into this issue in about 50% of our test runs. |
Hey, the reason this was failing is because you're specifying a filename and karma-webpack relies on the default filename to figure out how to map the webpack bundles to the karma files. I just merged a fix into next that will automatically correct this and we will cut a new version soon. For now if you just remove |
Expected Behavior
When I run
yarn run karma start config/karma.conf.js --single-run
it compiles the code and run testsActual Behavior
When i run
yarn run karma start config/karma.conf.js --single-run
it errors out on path receiving a undefined valueWorkaround
I found that if I simply
return
afternotifyKarmaAboutChanges
(effectively continuing the blocking until the next run of the compiler) then the issue no longer occurs.Other People stuck with similar issues:
Trace of the problem
As you can plainly see from the backtrace the issue is caused by a
undefined
being passed topath.join
. The line in question isand
this.outputs
(last parameter in call) is a blankMap
when it fails.I traced through the code a few times and found that only when this fails it calls
notifyKarmaAboutChanges
indone()
callback for the webpacker compile hook.However there seems to be a few issues with this
notifyKarmaAboutChanges
effectively triggers a rebuild but theisBlocked
flag is set to false at the end ofdone
, since that is a module level flag it when the compiler goes through a second time nothing will be blocked.notifyKarmaAboutChanges
is called it effectively starts compilation twice (that seems very funky to me, why does the done handler have a hook to rerun the compilation system?) -- You can see this via the trace above where the output clearly dumpsCode
How Do We Reproduce?
Its intermittent but simply running the test suite with a single large test file gives me about a 70-80% hit rate.
The text was updated successfully, but these errors were encountered: