Merge nucleic/lucid-river-toad-6efj into dev
This commit is contained in:
@@ -24,6 +24,11 @@ internal sealed class BrokerClient : IAsyncDisposable
|
||||
/// reader thread. Handlers must not block.</summary>
|
||||
internal event Action<string, JsonElement>? Notification;
|
||||
|
||||
/// <summary>Dump every inbound line. When a step hangs, the wire trace says whether the
|
||||
/// broker answered at all, answered and then went quiet, or never saw the request — three
|
||||
/// very different bugs that look identical from a timeout.</summary>
|
||||
internal bool Verbose;
|
||||
|
||||
private BrokerClient(Process process) => this.process = process;
|
||||
|
||||
internal static BrokerClient Spawn(string brokerPath)
|
||||
@@ -59,6 +64,8 @@ internal sealed class BrokerClient : IAsyncDisposable
|
||||
for (string? line; (line = await process.StandardOutput.ReadLineAsync()) is not null;)
|
||||
{
|
||||
if (line.Length == 0) continue;
|
||||
if (Verbose)
|
||||
Console.WriteLine($" [<-] {(line.Length > 300 ? line[..300] + "…" : line)}");
|
||||
JsonElement root;
|
||||
try { root = JsonDocument.Parse(line).RootElement.Clone(); }
|
||||
catch (JsonException) { Console.WriteLine($" [unparseable] {line}"); continue; }
|
||||
@@ -101,6 +108,7 @@ internal sealed class BrokerClient : IAsyncDisposable
|
||||
var request = args is null
|
||||
? $$"""{"jsonrpc":"2.0","id":{{id}},"method":"{{method}}"}"""
|
||||
: $$"""{"jsonrpc":"2.0","id":{{id}},"method":"{{method}}","params":{{JsonSerializer.Serialize(args)}}}""";
|
||||
if (Verbose) Console.WriteLine($" [->] {request}");
|
||||
await process.StandardInput.WriteAsync(request + "\n");
|
||||
await process.StandardInput.FlushAsync();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user