question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trying to start a workflow from asp.net and the client hangs

See original GitHub issue

What are you really trying to do?

Trying to start a workflow from asp.net minimal api.

Describe the bug

If I create the client at startup, and then try and use that client instance within an endpoint it hangs when I call StartWorkflowAsync.

If I create a client within the MapGet endpoint lambda it works.

Minimal Reproduction

using Temporalio.Client;
using Temporalio.Runtime;

var builder = WebApplication.CreateBuilder(args);

builder.Logging.AddSimpleConsole(options =>
{
    options.TimestampFormat = "yyyy-mm-ddTHH:mm:ss.ff ";
    options.UseUtcTimestamp = true;
    options.IncludeScopes = false;
    options.SingleLine = true;
});

// If I create the client here, when I call `client.StartWorkflowAsync` the call blocks and doesn't work.
var client = await TemporalClient.ConnectAsync(new()
{
    TargetHost = "localhost:7233",
    Namespace = "default",
});

var app = builder.Build();

app.MapGet("/", async () =>
{
    app.Logger.LogInformation("We are here");
    
    // NOTE: If I connect here it works
    // var client = await TemporalClient.ConnectAsync(new()
    // {
    //     TargetHost = "localhost:7233",
    //     Namespace = "default",
    // });

    var id = $"simple-workflow-{Guid.NewGuid().ToString()}";

    // This call blocks and doesn't work
    var handle = await client.StartWorkflowAsync(
        workflow: SimpleWorkflow.Ref.RunAsync,
        arg: "Jake",
        options: new WorkflowOptions(
            id: id,
            taskQueue: "my-task-queue"
        )
    );

    var result = await handle.GetResultAsync();
    return result;
});

app.Logger.LogInformation("Started");

app.Run();

Environment/Versions

  • x86 Windows
  • using temporal cli

Issue Analytics

  • State:closed
  • Created 5 months ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
cretzcommented, Aug 4, 2023

Good news. I can no longer replicate after updating core to get https://github.com/temporalio/sdk-core/pull/584 and setting my min tonic version to 0.9 and cargo updateing the bridge project. I will try to dig through Tonic release notes to see what it could be (though it could be one of their transitive dependencies).

I will update when I make a PR to fix this (I will likely wait for https://github.com/temporalio/sdk-core/pull/544 to be merged too).

0reactions
cretzcommented, Aug 8, 2023

I think it might be, yes. I’ll try to see if I can replicate via https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.testing.webapplicationfactory-1 in my unit tests without too much trouble.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why ASP.NET long running page request hangs forever for ...
Technically they run the report by hitting a button on the page which performs a post back to the server where the report...
Read more >
ASP requests hang if ILogger throws · Issue #10499
ASP.NET requests hang indefinitely if the ILogger being used throws a NotImplementedException from the BeginScope method.
Read more >
VS2019 Pro 16.8.4 C# ASP.NET Razor Page causes ...
I just want to report the errors in the ActivityLog.xml. See attachment. Just look for the errors. Fixed In: Visual Studio 2019 version...
Read more >
ASP.NET Workflow - Web Apps that Support Long-Running ...
In the application start event, I create the runtime, install the persistence service, and start the runtime. And in the application end event, ......
Read more >
Host and deploy ASP.NET Core Blazor WebAssembly
Learn how to host and deploy Blazor WebAssembly using ASP.NET Core, Content Delivery Networks (CDN), file servers, and GitHub Pages.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found