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

Streaming example from readme deadlocks if seq instance is restarted #140

Open
akilin opened this issue Dec 31, 2024 · 1 comment
Open
Labels

Comments

@akilin
Copy link

akilin commented Dec 31, 2024

Seq event streaming from readme deadlocks when disposing the stream when the seq instance is restarted.

I am attempting to stream seq events for additional processing. I was testing how it handles the scenario where the seq instance is restarted, and it appears to deadlock when disposing of the stream.

var seqUrl = "http://localhost:5341";

Log.Logger = new LoggerConfiguration()
    .WriteTo.Seq(seqUrl)
    .WriteTo.Console()
    .CreateLogger();

var filter = "@Level = 'Error'";

var connection = new SeqConnection(seqUrl);

while (true)
{
    await connection.EnsureConnectedAsync(TimeSpan.FromSeconds(15));
    
    var stream = await connection.Events.StreamAsync<JObject>(filter: filter);

    var subscription = stream.Subscribe(
        log => Log.Information("OnNext"),
        ex => Log.Information("OnError"),
        () => Log.Information("OnCompleted")
    );

    await Task.Delay(1000);
    Log.Error("logging fake error to test seq streaming");

    await stream;

    subscription.Dispose();
    stream.Dispose(); // <-- stuck here

    Log.Information("loop end");
}

It seems to get stuck while waiting for _run task to finish here:

_run.ConfigureAwait(false).GetAwaiter().GetResult();

Repo with reproduction: https://github.com/akilin/demos/tree/master/seq-stream

Steps to reproduce:

  • clone the linked repo
  • navigate to seq-stream folder
  • docker-compose up
  • run the dotnet app and wait until you see OnNext in the console logs
  • docker-compose restart (to restart seq and close the stream)
  • app deadlocks when disposing the stream
@KodrAus KodrAus added the bug label Jan 1, 2025
@KodrAus
Copy link
Member

KodrAus commented Jan 1, 2025

Thanks for the report @akilin. If you're attempting to hang-up from the client-side of the stream we shouldn't block. Since the websocket is closed by the server on restart I would've expected it to throw, but we'll investigate and see what's going on there.

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

No branches or pull requests

2 participants