Repository navigation
Make compat binary console logging non-blocking - #732
Draft
todthomson wants to merge 2 commits into
Draft
todthomson wants to merge 2 commits into
todthomson wants to merge 2 commits into
Conversation
The compat binaries log every Halibut event and service call with a synchronous Console.WriteLine on the request path. When the test process stops reading the compat binary's stdout, the pipe buffer fills and the next write blocks, freezing the whole binary (LEV-2253). Route compat binary console output through NonBlockingConsole, which queues lines (bounded) for a background thread and drops and counts lines rather than blocking. Startup lines are flushed before continuing, and output is flushed before exit. FixHungWebSocketsHack keeps its direct console write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012CQ12H5eAC2buLoec1L71V
Links the compat binary's NonBlockingLineWriter into Halibut.Tests and checks it keeps order, never blocks callers when the target is blocked, reports dropped lines once output resumes, times out flushes on a blocked target, and survives a throwing target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012CQ12H5eAC2buLoec1L71V
|
|
1 of 3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
The nightly Halibut chain has been blocked every few days by a single net48 test timing out against the out-of-process 5.0.236 compat binary (Linear LEV-2253). The trace logs from two of those failures (
7Nq4O5056Dand3rIE6fZPSs, build 10.0.2247) show the same sequence:The compat binary logs every Halibut event and every service call with a synchronous
Console.WriteLineon the request path. So once the test-side stdout reader stops draining the pipe, the next write blocks, and the Halibut protocol in the compat binary blocks with it.This PR doesn't explain why the reader stops. That's being investigated separately; the CliWrap 3.8.2 → 3.10.5 bump in #724 is a suspect. What it does is stop a stalled reader from freezing the binary under test.
Results
NonBlockingLineWriterand aNonBlockingConsolewrapper toHalibut.TestUtils.CompatBinary.Base. Lines are queued (bounded at 10,000) and written to stdout by a dedicated background thread.[NonBlockingLineWriter] N log line(s) were dropped…line is written once output resumes.NonBlockingConsole.Listening on port,RunningAndReady) are flushed before the binary continues.FixHungWebSocketsHackkeeps its directConsole.WriteLine, since the write itself is what that hack relies on. It runs on its own background thread, so it can't block the protocol.NonBlockingLineWriterFixturecovers the writer:The source file is linked into
Halibut.Tests, so the test project doesn't reference a compat binary and its old Halibut package.Relates to Linear LEV-2253.
Before
A stalled stdout reader on the test side freezes the compat binary. The test then fails with a read timeout, or with a polling request that is never collected.
After
A stalled stdout reader only delays (or eventually drops) compat binary log lines. The compat binary keeps serving requests.
How to review this PR
Quality ✔️
Halibut.TestUtils.CompatBinary.Basefor both net48 and net10.0 locally.NonBlockingLineWriterFixturethree times, plus the 42UsageFixture.OctopusCanSendMessagesToTentacle_WithEchoService/_WithSupportedServicescases, which include the 5.0.236 variants. All passed.BackwardsCompatProgramBaseandProxyServiceForwardingRequestToClient, and keepingFixHungWebSocketsHackon the direct console write.Pre-requisites
Generated by Claude Code