An error in the config makes Karate hangs
See original GitHub issueI have a project running Karate 0.9.6.RC2.
In the karate-config.js
there is this call: karate.callSingle('classpath:utils/get-token.feature', config)
When this feature fails, when it fetches an url to an unknwon host for instance, or with bad http credentials, Karate reports that it has failed but the process never terminates.
I quickly tested with 0.9.6.RC3, same issue. This issue doesn’t appear with 0.9.5.
I have then tested on the develop branch, commit b7a5010b, and encoutered the hanging on failure. I have been able to enter a java debugging session, and I have seen the possible source of the bug.
This issue seems to be a NPE in karate-core/src/main/java/com/intuit/karate/core/ScenarioExecutionUnit.java
line 150, because juste above at the line 139 an exception was raised then catched.
I don’t know what a good fix for this issue is, but a quick test with this patch makes karate terminate in case of error:
Index: karate-core/src/main/java/com/intuit/karate/core/ScenarioExecutionUnit.java
===================================================================
--- karate-core/src/main/java/com/intuit/karate/core/ScenarioExecutionUnit.java (revision b7a5010b31839194962d8ca77c0a7233d76fc3e8)
+++ karate-core/src/main/java/com/intuit/karate/core/ScenarioExecutionUnit.java (date 1594388677424)
@@ -147,7 +147,9 @@
actions.context.setLogger(logger);
}
// this flag is used to suppress logs in the http client if needed
- actions.context.setReportDisabled(reportDisabled);
+ if (actions != null) {
+ actions.context.setReportDisabled(reportDisabled);
+ }
// this is not done in the constructor as we need to be on the "executor" thread
hooks = exec.callContext.resolveHooks();
// before-scenario hook, important: actions.context will be null if initFailed
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (6 by maintainers)
I just tried with your fix ea87a557, Karate terminates even in case of error in the init. Thanks!
@vs-dsva thank you for reporting this and confirming the fix 👍 don’t worry about the
2.0.0
that’s just the dummy version we use for the in-dev version