Skip to content

Handling long running operation in VisualizerObjectSource #325

Open

Description

In my EFCore.Visualizer project I have a custom VisualizerObjectSource that retrieves query plan. But in some cases, if the query is complex or database connection is slow the time to retrieve the plan exceeds the five seconds timeout that third party visualizers have and users get Evaluation timed out error

I tried to implement a solution according to Work with large and complex objects but in my case I can't break down plan retrieval into smaller actions. Instead, my idea was to start a long running task with Task.Run and call RequestDataAsync until the task is finished. But this approach doesn't work either because when VS is in break mode it doesn't run other threads so I get: StreamJsonRpc.RemoteInvocationException: cannot evaluate expression since the function evaluation requires all threads to run.

Is there any way to tell VS to run my task or is there some other way to execute long running operation without causing timeout from VS?

Activity

  1. mpeyrotc commented on Feb 29, 2024

    @mpeyrotc
    Member

    Hello Giorgi Dalakishvili (@Giorgi), sadly that is a limitation that the debugger enforces to every evaluation that happens within the debugger. In the case of visualizers, no evaluation can take more than 5 seconds. I will see if there is anything that can be done to make your visualizer work and then get back to you. Thanks!

  2. Giorgi commented on Feb 29, 2024

    @Giorgi
    Author

    Yes, I understand that there is a 5-second limit for the RequestDataAsync but I could call it in a loop if there was a way to use Task.Run inside debuggee without getting StreamJsonRpc.RemoteInvocationException

  3. ElectricVampire commented on Jun 18, 2025

    @ElectricVampire

    Hello @Giorgi, sadly that is a limitation that the debugger enforces to every evaluation that happens within the debugger. In the case of visualizers, no evaluation can take more than 5 seconds. I will see if there is anything that can be done to make your visualizer work and then get back to you. Thanks!

    Any solutions for this problem?

  4. teo-tsirpanis commented on Aug 28, 2025

    @teo-tsirpanis

    Giorgi Dalakishvili (@Giorgi), something you can do is move the visualizer's logic to a library, and have users explicitly call a ComputeQueryPlan(Async) method, if the IQueryable<> visualizer causes them timeouts. The methods will return a custom object that you can still visualize like before. Users will have to change their code and install a NuGet package, but only as a fallback if they are getting timeouts.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions