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

Host is disposed too early when running projection rebuild command #2450

Closed
davit-asryan-sveasolar opened this issue Jan 9, 2023 · 1 comment · Fixed by #2453
Closed

Comments

@davit-asryan-sveasolar
Copy link

davit-asryan-sveasolar commented Jan 9, 2023

Host is disposed too early when running projection rebuild command.

using System.Threading.Tasks;
using Oakton;

namespace Marten.CommandLine.Commands.Projection;

[Description("Marten's asynchronous projection and projection rebuilds")]
public class ProjectionsCommand: OaktonAsyncCommand<ProjectionInput>
{
    public override Task<bool> Execute(ProjectionInput input)
    {
        using var host = input.BuildHost();

        var controller = new ProjectionController(new ProjectionHost(host), new ConsoleView());
       // possibly should be awaited here?
        return controller.Execute(input);
    }
}
@gfoidl
Copy link
Contributor

gfoidl commented Jan 10, 2023

You refer to

using var host = input.BuildHost();
var controller = new ProjectionController(new ProjectionHost(host), new ConsoleView());
return controller.Execute(input);

Then for

// possibly should be awaited here?

Yes. Otherwise the host will get disposed on return from that function while the Execute is still executing. That's a 🐛.

Do you want to submit a PR for this? (Otherwise I'll send one).

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

Successfully merging a pull request may close this issue.

3 participants