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

Getting DynamicContext error after upgrading to Karate 1.1.0 from 1.1.0.RC4 #1711

Closed
DeepakNaik30 opened this issue Aug 10, 2021 · 4 comments

Comments

@DeepakNaik30
Copy link

DeepakNaik30 commented Aug 10, 2021

Hi,
I am getting "DynamicContext could not be passed from one context to another" error message after upgrading to Karate 1.1.0 from 1.1.0.RC4.
To reproduce the issue, I have created a sample project with Karate 1.1.0 archetype and added the related code that throws the message.

From karate-config.js, I am doing karate.callSingle to utility.feature file.
image

utility.feature makes a call to HelloWorld.java class that has 1 static method which prints "Hello World..!!" to the console.
I changed the method to static after reading other stack overflow pages related to this Dynamic error for Karate 1.0.0

image

image

From users.feature file, I am doing callonce to another feature file in the Background.
And inside Scenario, I am calling this helloWorld method, but this line 13 throws the message of ""DynamicContext could not be passed from one context to another"
image

If I change the Karate version to 1.1.0.RC4, scenario gets executed successfully, but throws DynamicContext message with Karate 1.1.0.RC5 and 1.1.0 versions.

Note: I tried most of the solutions I could find on stack overflow or Karate github issues pages, but not able to fix this issue.
Maybe I am missing a minor code change here.
Can someone please help ?

I have attached the zip of sample project, to reproduce the issue.
DynamicContextError.zip

@ptrthomas
Copy link
Member

@DeepakNaik30 I don't consider this a priority especially since you don't seem to have tried RC5 and given us the feedback. please consider using the information available to narrow down the problem or find a work around. I'm taking a little break from trying to solve this. and have you read the docs that say that mixing java code into callSingle / callonce is "at your own risk". all the best.

@ptrthomas
Copy link
Member

@DeepakNaik30 many thanks for the simple example, the interesting thing is this has nothing to do with Java or static methods, the problem is because a JS function was returned in callSingle() and you are trying to use it.

cc @joelpramos I have added a test to replicate and if you un-comment the lines in js-call.feature you will see the problem: 4bd469c

I'm closing this as wontfix for now. yes it may have worked in RC4 - but we did some very significant performance optimizations in RC5 and I don't want to take a performance hit just because some users want to mix functions into callSingle() even though we tell them not to: #1685

that said, there is a good chance that a future version of the JS engine will support JS functions being passed around - and that should put an end to all these woes: oracle/graal#631 (comment)

anyone is welcome to disagree and fix this in karate in the meantime.

@ptrthomas
Copy link
Member

@DeepakNaik30 further investigation found that this is not related to callSingle() it would help a lot if you can re-test after the fix made in #1725

@DeepakNaik30
Copy link
Author

Hi @ptrthomas Fix in Karate develop branch is working for us. We no longer see this DynamicContext error.
Looking forward to have this fix in 1.2.0.RC1 next week

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

No branches or pull requests

2 participants