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

[BUG] Event payload missing when an event bookmark is resumed. #5933

Closed
JaFonz opened this issue Aug 29, 2024 · 1 comment
Closed

[BUG] Event payload missing when an event bookmark is resumed. #5933

JaFonz opened this issue Aug 29, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@JaFonz
Copy link
Contributor

JaFonz commented Aug 29, 2024

Description

As per this issue, the event payload is missing. This fix only applies to events which trigger a workflow, not for events which are mid-workflow and use bookmarks to suspend and resume.

Steps to Reproduce

We are using the Elsa Studio to define the workflows.:

  • In one workflow, publish an event with a payload.
  • In another workflow, have an event activity which is not a workflow trigger which subscribes to the publish event from the workflow.
  • Start the second workflow with the event activity which will run and suspend at the event activity.
  • Run the first workflow with the publish activity which will publish the event and complete.
  • The second workflow will resume and complete, however the event payload will not be in the event result.

On further investigation, modifying the ExecuteAsync method in Event.cs to add a callback which retrieves the payload from the WorkflowInputMessageInbox resolves this issue:

protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
    {
        var eventName = context.Get(EventName)!;

        if (!context.IsTriggerOfWorkflow())
        {
            var options = new CreateBookmarkArgs
            {
                Stimulus = new EventStimulus(eventName),
                IncludeActivityInstanceId = false,
                Callback = OnResumeAsync
            };
            context.CreateBookmark(options);
            return;
        }

        var input = context.GetWorkflowInput<object?>(EventInputWorkflowInputKey);
        context.SetResult(input);
        await context.CompleteActivityAsync();
    }

    private async ValueTask OnResumeAsync(ActivityExecutionContext context)
    {
        var input = context.GetWorkflowInput<object?>(EventInputWorkflowInputKey);
        context.SetResult(input);
        await context.CompleteActivityAsync();  
    }

I have made the changes above in a fork and am happy to raise a PR if this is acceptable.

@JaFonz JaFonz added the bug Something isn't working label Aug 29, 2024
@sfmskywalker
Copy link
Member

Thanks for the bug report + PR that fixes it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants