Open LukasBenner opened 7 months ago
Based on the provided context and the workflow JSON, it seems that the delay you are experiencing after the for loop finishes and before the HTTP response is returned could be related to the way the workflow is being executed and how the HTTP response is being handled within the Elsa workflow engine.
The Elsa.HttpEndpoint
activity is designed to handle incoming HTTP requests and can be configured to start a workflow. When the workflow is triggered by an HTTP request, the workflow will execute until it reaches a point where it needs to suspend and wait for another event (like another HTTP request) or until it completes. If there is a delay after the for loop and before the HTTP response is returned, it could be due to the workflow execution still being in progress or some post-execution processing that is happening within the Elsa engine.
The additional 1-2 seconds delay after the for loop could be due to the workflow engine finalizing the workflow execution and preparing the HTTP response. This could involve internal processing like logging, persistence, or other housekeeping tasks that the workflow engine needs to perform.
Regarding the inability to call the second HTTP endpoint until the first one returns, this could be due to the workflow instance being in a suspended state waiting for the first HTTP request to complete. If the workflow is designed to wait for an HTTP request at a certain point, it will not be able to process another request until the current one is completed and the workflow has been resumed.
To address these issues, you may want to review the workflow design and ensure that the activities are configured correctly. Additionally, you can look into the Elsa documentation and community resources for best practices on handling HTTP requests and responses within workflows.
If you believe there is a configuration issue or a bug within the Elsa workflow engine, you can reach out to the Elsa community on GitHub or Stack Overflow for further assistance.
Since the delay is not expected behavior and could be specific to your setup or a potential issue with the Elsa workflow engine, I would recommend checking the following:
If you provide more specific details about the delay or the behavior of the HTTP endpoints, I may be able to offer more targeted advice.
Ok so here is some additional information:
I use the latest NuGet package of Elsa which is Version 3.0.5
The workflow only uses basic activities:
The workflow is the following:
The logs show no errors or warnings
I think this is related to #4701
for my comprehension, return of HTTPEndpoint is done when the workflow is suspended or finished. And at this point, some log & process are flush. The end of the response seems to in sync with some of theses processes.
This issue is identified.
thx
I think @jdevillard is correct; the description of this issue made me think of #4701 as well.
I noticed some delays in workflows that use a for or a while loop and http endpoints. A simple example is a workflow, that is triggered by an http endpoint and a for loop that is followed by another http endpoint.
The delay isn't in the execution of the workflow but in the request to the http endpoint.
I trigger the workflow by calling the endpoint, the for loop starts and prints to the console. After 1000 iterations the the loop ends and the output in the console stops. Another 2 seconds later, the request to the endpoint returns with status 200. Why does the request return AFTER the for loop finished and why does it take another 1-2 seconds? A real problem occurs if there is another http endpoint after the for loop. I can't call the second endpoint until the first endpoint returned.
I don't knwo if this problem is caused by a poor configuration so I'll post the code of Program.cs
The workflow is rather simple: