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

Having a long timeout results in StackOverflowException #388

Closed
ghost opened this issue Oct 16, 2017 · 7 comments
Closed

Having a long timeout results in StackOverflowException #388

ghost opened this issue Oct 16, 2017 · 7 comments

Comments

@ghost
Copy link

ghost commented Oct 16, 2017

Our application has a pretty long startup time. Therefore I have to set the timeouts to a value bigger than 1 minute. If I now run multiple tests in parallel (with different AppDomains in the same dll) sometimes a StackOverflowException is thrown.

Would it be possible to do the waiting in wait.fs without the recursion?

@lefthandedgoat
Copy link
Owner

lefthandedgoat commented Oct 16, 2017

I must have not written it in a way to where the tail call optimization kicks in.

What timeout setting causes the StackOverflow? If I can repro I can fix it.

@ghost
Copy link
Author

ghost commented Oct 17, 2017

Ok, that was a bit harder to properly reproduce but here is an example where the tail call optimization doesn't work and the stack trace gets longer and longer.

using System.IO;
using canopy;
using _ = canopy.csharp.canopy;

namespace CanopyTest
{
    public class Program
    {
        public static void Main(string[] args)
        {
            configuration.chromeDir = Directory.GetCurrentDirectory();
            configuration.elementTimeout = 30;
            _.start(types.BrowserStartMode.Chrome);

            _.url("https://www.w3schools.com/css/css_display_visibility.asp");
            _.click("#panel");

            _.run();
            _.quit();
        }
    }
}

The problem only occurs when the element is not visible. If it's not there at all then the stack trace is small.

I'm not sure though if this really solves my problem as there is no stack trace is available when a StackOverflow exception happens. But this might cause it.

@lefthandedgoat
Copy link
Owner

I will try to re-order the recursive calls so that the tail call optimization works and it never causes a stack overflow. Thanks for the repro!

@lefthandedgoat
Copy link
Owner

I moved to a loop instead of recursion which should fix the StackOverflowException. It also cleans up the exception to not have the same message repeated over and over.

https://www.nuget.org/packages/canopy/1.5.3

@forki
Copy link
Contributor

forki commented Oct 19, 2017

@lefthandedgoat can you try to apply same thing to canopy.mobile? I see SOs from time to time

@ghost
Copy link
Author

ghost commented Oct 19, 2017

Thanks for the update!
Looks good to me now.

@ghost ghost closed this as completed Oct 19, 2017
@forki
Copy link
Contributor

forki commented Oct 19, 2017

Latest Canopy.Mobile is also fixed. Awesome

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

No branches or pull requests

2 participants