-
Notifications
You must be signed in to change notification settings - Fork 21
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
Gauge freezes when running async methods #199
Comments
Not at the computer but what happens when you make the method async? If my memory is right, gauge-dotnet honours async implementations |
Execution just halts. I don't know the details of how the plugin works but it freezes trying to execute the task. Thanks for replying, we really like Gauge and we use it in several projects and we hope we can continue to do so even if we understand that the development/support is very limited... If you have time I have created a minimal step/spec impl that reproduces the problem, no dependencies needed: |
I guess I wasn't clear. I was suggesting something like this (from your sample project):
The PS - apologies for closing the issue accidentally. |
If I run you step above you are correct that it does no longer freeze, but maybe I should rephrase my problem: The output from your example above is be:
The result from DoSomethingAsync() is not waited for and the following prints are not executed, the test execution just continues (in this case completes). I need to be able to wait for DoSomethingAsync to complete and then run the next line of code, just as if the code was synchronous. That is, how do I wait for the result of DoSomethingAsync() before continuing execution of the test (step)? I expect/need the following output from the example:
|
Strange, I see this:
Are you sure you are awaiting
I will try to send you a PR with my changes if that helps |
Sorry for the confusion. I have commented out the first step, that's why the output differ (see below). Your output as well indicates that the 2nd step does not complete, you don't have the output "Done something." & Completed" for that step.
Yes, I await. Step:
|
Thanks for the clarification. I can see what you mean. Will try to release a fix, I have a hunch on what's missing |
If find the problem and you're going to make new release, feel free to add .NET 8 support as well :) |
I've raised a PR with a potential fix for this. But then I also remembered that i.e this is not good:
and instead it should be this:
I am trying to see how to guard against this, should gauge-dotnet break execution? Any thoughts? |
Hi! So async methods would need to return a Task to work as expected and otherwise we want to halt exectuion? Fair enough. From a user perspective I think it would be fine if Gauge skips the scenario if an async step-method does not return as Task in a similar way as it does when a step implementation is missing: But with another descriptive error message, e.g. "Async step implementations must have return type Task". Keep me updated about your progress. We started looking at this last week, but didn't solve it so we are eager to see a proposed solution. |
the entire method execution chain is now async Signed-off-by: sriv <[email protected]>
the entire method execution chain is now async Signed-off-by: sriv <[email protected]>
the entire method execution chain is now async Signed-off-by: sriv <[email protected]>
* check if method is async and await results, #199 Signed-off-by: sriv <[email protected]> * Add .NET 8 support (#200) * Add .NET 8 support Signed-off-by: Martin Pekurny <[email protected]> * Update the init command to create a newer csproj file and removed the matrix for different dotnet versions in the build.yml Signed-off-by: Martin Pekurny <[email protected]> * Limiting the number of nodes to use for the feature tests Signed-off-by: Martin Pekurny <[email protected]> --------- Signed-off-by: Martin Pekurny <[email protected]> Signed-off-by: sriv <[email protected]> * add check to guard against async void impl step implementations with async void are treated as not implemented Signed-off-by: sriv <[email protected]> * bump version 0.6.0 Signed-off-by: sriv <[email protected]> * fix nunit assert syntax Signed-off-by: sriv <[email protected]> * make MethodExecutor.Execute handle async, #199 the entire method execution chain is now async Signed-off-by: sriv <[email protected]> * preserve arguments check when executing hook Signed-off-by: sriv <[email protected]> --------- Signed-off-by: sriv <[email protected]> Signed-off-by: Martin Pekurny <[email protected]> Co-authored-by: mpekurny <[email protected]>
Reopened due to getgauge/gauge#204 |
@jensakejohansson have you tried out the new async update? While it seems that there might be a new issue described here, #241, can we close this issue? |
I have problems with Gauge/C# that the execution halts whenever async-methods are invoked and the result is waited for. This makes it difficult to use, for example, Playwright with Gauge since it only provides an async API for dotnet. Example:
If you execute this step it will stop at the first line indefinitely and never return. To be clear, it's not Playwright specific, any async method-call that you wait for like this seems to result in some sort of deadlock.
A work-around is to run the code in a seperate thread, which works:
However, this does not scale well in our test framework and alot of complexity arises without providing anything but problems...
@sriv Any idea why the first example freezes Gauge? This is unfortunately a quite serious limitation in Gauge/C#.
The text was updated successfully, but these errors were encountered: