question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

An error in the config makes Karate hangs

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
hibnicocommented, Jul 10, 2020

I just tried with your fix ea87a557, Karate terminates even in case of error in the init. Thanks!

0reactions
ptrthomascommented, Mar 10, 2021

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

An error in the config makes Karate hangs #1216 - GitHub
I 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' ...
Read more >
Karate Tests Stuck on Running Forever - Stack Overflow
Some tests would run as it was perfectly fine. But at some point the rest will just stuck as it it hangs. We...
Read more >
Testing a Java Spring Boot REST API with Karate - Semaphore
Learn how to write web service tests with Karate, a new framework for scripting HTTP sequences specifying expectations.
Read more >
Karate Gatling
Most problems when using Karate with Gradle occur when “test-resources” are not configured properly. So make sure that all your *.js and *.feature...
Read more >
Getting Started With Karate Test Framework for API
The same argument is valid the karate-config.js file. However, creating a new src/test/karate folder and making this a source folder like it's ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found