-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Process exits without exceptions or logs when using karma.config.parseConfig
#3631
Comments
This appears to be similar to, but different from: #3612 |
I agree that current behavior is inconvenient. We should continue to clean up these I would suggest introducing a helper function that can be used instead of const fail = (message) => {
log.error(message);
if (throwErrors) {
throw new Error(message);
} else {
log.warn('`parseConfig()` function used to call `process.exit(1)` when config parsing failed. This behavior is now deprecated and function will throw an error in the next major release. To suppress this warning pass `throwErrors: true` as a third argument to opt-in into the new behavior and adjust your usage accordingly. Example: `parseConfig(path, options, { throwErrors: true })`');
// ^^^ or something along these lines to convey the idea to the consumers
process.exit(1);
}
} Then update Line 66 in e246461
(done || process.exit)(1) callback directly.
|
I can try taking a swing at it. Let's see how far I can get. Does this project maintain a I don't see anything in the contributing docs/webpages about what kind of work flow this repository uses. (I'm used to working with some variation of GitFlow) |
We just use the simple github solution: create a fork on your github account and branches you push to your repo can be converted to pull requests in the github UI. We squash PRs so you can have multiple commits. |
Understood. Thanks! |
Fixed by #3635 |
I'm using
karma.config.parseConfig
to create a configuration using the public API:https://karma-runner.github.io/6.0/dev/public-api.html
And my code has no way of being notified of errors. For example, the process exits silently if you pass a relative path to
parseConfig
. No exceptions are thrown and the logger doesn't output any messages to the console. Neither me (via the console) nor my application (via thrown exceptions) has any way of knowing that something went wrong.I am aware that using the CLI, it would use
path.resolve
to create an absolute path, but that is not the issue. I want to be informed about problems with the input being provided so that I can then tell the user or take some kind of action based on the kind of error it is.EXAMPLE
RELATED CODE
karma/lib/config.js
Lines 6 to 7 in e246461
karma/lib/config.js
Lines 354 to 424 in e246461
ROUGH START
Log4js isn't setup until the function is almost done, this might explain why logging doesn't seem to be enabled. I'm not familiar with that library, so I am not sure what a good solution would look like, but a possible work around for critical errors that normally exit the process might look like the following:
Any functions that
parseConfig
calls, such asnormalizeConfig
, would need similar accomadations.CLOSING
I feel like I may be missing something obvious and I just haven't seen the documentation or code for it yet. Could someone help point me in the correct direction if this is something that already works?
The text was updated successfully, but these errors were encountered: