-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
DynamicObject<JSFunction> context error when using karate.callSingle and karate.merge in karate-config.js #1883
Comments
@hueller my first reaction is that this will be hard - so I'm going to come back to this later. my advice would be to make any "common" routines you need Java code since I am assuming (just speed reading the above) that you are trying to re-use stuff across 2 java maven modules - which will be a challenge in pure JS some relevant discussion and work-arounds here (sorry, long read): #1558 the other reason why I will not rush to solve this is that Graal issue number 631 (see link above) may solve this horrible JS limitation once and for all. I need to find time to upgrade karate's graal dep and remove all the ugly JS context-swapping code we have right now |
Ok thanks, but how can I use Java code for common routines without declaring them within JavaScript functions in .feature files? That's what I'm already doing in the attached example:
And yes, what I want to achieve is to define common routines in one shared Maven module, which I can include in multiple concrete Karate projects. As mentioned above, this is working in general, but the additional usage of Also the |
@hueller you can reuse java easily because it just needs to be on the classpath. please refer: https://stackoverflow.com/a/58339662/143475 |
Ok, thanks! Looking forward for the Karate release which includes the Graal VM fix. For now I'll try to implement a workaround to not rely on the karate.merge call anymore (which seems to break my setup) and also on using Java for reusable functions/methods. |
@ptrthomas - I am trying to migrate my common utilities JS functions to Java. I use couple of JS functions provided by karate currently. e.g., karate.prevRequest is there a way to replicated them in Java directly? |
@pshrm |
tagging a reference for some planned refactoring: oracle/graal#631 (comment) |
still an issue with parallel scenario, but no longer the multi-thread issue guess is that variables are being over-written by another scenario-thread websocket may not be possible to do with custom js functions so we will limit or revise existiing documented approach
feels good to get rid of that horrible recurse and attach stuff
in small steps because of how much trouble this caused in the past
note that this commit reverts the change made in #1835
my guess is that this was the source of the flakyness and how we swallowed the exception before
this should be the last of the graal upgrade and js fixes
@hueller I think this is finally fixed ! I haven't tried your sample project yet, and if you can use the |
the extra graal value coercion seems to be reason for websocket test being flaky in ci
well, the current working theory is that the more locks and sleeps we put in the more likely threads run into each other
1.3.0 released |
I know that there have already been several bug reports related to DynamicObject context errors, but I'm still able to reproduce an issue also against the current Karate develop branch.
Please find attached my sample project, which contains two Maven projects:
To reproduce the issue, first myproject-helpers needs to be built (
mvn install
) and thenUsersRunner
in myproject can be executed:mvn test -Dtest=UsersRunner
The two .feature files in myproject-helpers are used in the following way in myproject:
utils.feature
gets called viacall read
in the first scenario ofusers.feature
, which in general works fine:However, it stops working with the DynamicObject context error, when I try to include the second .feature file
markers.feature
viakarate-config.js
. Thismarkers.feature
file contains a self-validating expression, which I want to make 'globally' available by merging it into theconfig
object:karate.callSingle
alone doesn't seem to cause an issue. But when alsokarate.merge
gets called, the above mentionedcall read('classpath:examples/helpers/utils.feature@getUUIDUtils')
fails with the DynamicObject context error.I have no idea why this is happening and if there are other options to make self-validating expressions globally available, so I appreciate your help! Thanks a lot!
Archive.zip
The text was updated successfully, but these errors were encountered: