Skip to content

Tests: a hang guard that fires disposes the event enumerator while its pull is pending #576

Closed as not planned

Description

@Blind-Striker

Most event-bus rows start a pull without waiting for it (PendingNext, PendingCancellationAsync,
or a local reader task), move the manual clock, and then wait for the pull under HangGuard.Bound.
The enumerator belongs to an await using declaration. If the hang guard fires, the
TimeoutException unwinds into DisposeAsync while the MoveNextAsync is still pending. The
disposal can then throw a concurrent-use exception that replaces the guard's message, and the pull is
left unobserved. The row is already red, so no false green follows, but its failure report is
harder to read, and the pending task's exception goes unobserved.

The shape predates the characterization for #483: 27 of these sites are in
EventsClientReconnectTests at 9afb32d4. Review on 2026-10-24 found the problem but left it
outside that characterization because it is file-wide.

Historical rows identified by that review (not the current conversion list; #902 removed per-call
location forwarding and the minute give-up, and src/OpenCode.Sdk/Events/EventsClient.cs now
specifies indefinite retries):

  • Events/EventsClientReconnectTests: Per_Call_Location_Should_Be_Sent_On_Every_Reconnect_Attempt,
    A_Dropped_Stream_Should_Reconnect_After_One_Second_And_Announce_It_With_Server_Connected,
    The_Clients_Network_Timeout_Should_Not_Reach_The_Bus,
    An_Attempt_Should_Be_Cut_When_It_Does_Not_Connect_Within_2_Seconds,
    Every_Failed_Open_Should_Be_Followed_By_A_New_Attempt,
    A_First_Event_That_Is_Not_Server_Connected_Should_Not_Be_Delivered (a local reader task),
    Every_Drop_Of_A_Connected_Stream_Should_Be_Followed_By_A_New_Attempt,
    A_Stream_Refused_For_A_Minute_Should_Throw_The_Declared_Error_Exactly_At_The_Minute,
    The_Give_Up_Should_Throw_The_Latest_Failure, An_Ended_Stream_Should_Report_The_Ended_Text_At_Give_Up,
    The_Give_Up_Should_Cut_An_Attempt_In_Flight_And_Throw_The_Failure_Before_It,
    A_Stream_Failed_By_The_Server_For_A_Minute_Should_Throw_The_Typed_Failure_Cause,
    A_Server_That_Never_Answers_Should_Throw_The_Connect_Bound_Exactly_At_The_Minute,
    A_Server_That_Answers_Without_An_Event_Should_Throw_The_Connect_Bound_At_Give_Up,
    A_Server_Whose_Error_Body_Stalls_Should_Report_An_Answer_At_Give_Up,
    A_Connection_Should_Restart_The_Minute_From_Its_Drop,
    The_Callers_Token_Should_End_The_Stream_During_The_Delay_Without_Another_Attempt,
    The_Callers_Token_Should_End_A_Connected_Stream_Without_Another_Attempt,
    A_Disposed_Client_Should_End_The_Stream_At_Once.
  • Events/EventsClientIdleWindowTests: A_Connected_Stream_Should_Be_Cut_After_45_Seconds_Without_A_Byte,
    A_Configured_Idle_Window_Should_Cut_A_Silent_Stream_Exactly_When_It_Passes,
    A_Heartbeat_Should_Start_A_Configured_Idle_Window_Again,
    Bytes_Before_Server_Connected_Should_Leave_The_Connect_Bound_In_Charge,
    A_Single_Byte_Should_Start_The_Idle_Window_Again, A_Heartbeat_Should_Keep_A_Quiet_Stream_Open.

Current pending-pull sites to re-check after #902:

  • tests/OpenCode.Sdk.Tests/Events/EventsClientReconnectTests.cs:
    SubscribeAsync_Should_Send_Only_The_Ambient_Location_Or_Refuse_The_Raw_Spine,
    SubscribeAsync_Should_Send_The_Client_Wide_Headers_On_Every_Attempt,
    A_Dropped_Stream_Should_Reconnect_After_One_Second_And_Announce_It_With_Server_Connected,
    The_Clients_Network_Timeout_Should_Not_Reach_The_Bus,
    An_Attempt_Should_Be_Cut_When_It_Does_Not_Connect_Within_2_Seconds,
    Every_Failed_Open_Should_Be_Followed_By_A_New_Attempt,
    A_First_Event_That_Is_Not_Server_Connected_Should_Not_Be_Delivered,
    Every_Drop_Of_A_Connected_Stream_Should_Be_Followed_By_A_New_Attempt,
    The_Callers_Token_Should_End_The_Stream_During_The_Delay_Without_Another_Attempt,
    The_Callers_Token_Should_End_A_Connected_Stream_Without_Another_Attempt,
    A_Disposed_Client_Should_End_The_Stream_At_Once,
    The_Callers_Cancellation_Should_Win_Over_Disposal_During_The_Delay,
    A_First_Event_Refusal_Should_Report_The_Exact_First_Frame_Text,
    AssertOpeningTransportFailureMessageAsync.
  • tests/OpenCode.Sdk.Tests/Events/EventsClientIdleWindowTests.cs:
    A_Connected_Stream_Should_Be_Cut_After_45_Seconds_Without_A_Byte,
    A_Configured_Idle_Window_Should_Cut_A_Silent_Stream_Exactly_When_It_Passes,
    A_Heartbeat_Should_Start_A_Configured_Idle_Window_Again,
    Bytes_Before_Server_Connected_Should_Leave_The_Connect_Bound_In_Charge,
    A_Single_Byte_Should_Start_The_Idle_Window_Again.

The two shared helpers that own a pending pull, EventStreamSteps.WithPendingCancellationAsync and
SubscribeConnectedAsync, received their failure-path cleanup during the characterization for
#483, following other findings from the same review. They are not part of this record.

Proposal: one owner for "a pull that may still be pending at teardown": cancel it, observe it under
its hang guard, then dispose the enumerator, keeping the guard's failure as the reported one. Move
the affected current rows onto it after re-checking the sites above. The historical roster is
not the conversion list. This was originally planned alongside the reconnect-owner extraction in
#483, which moved these rows' subject.

Originally part of #483, which is now closed. Part of #498.

Activity

  1. added this to the 1.1 milestone on Nov 6, 2026
  2. Blind-Striker commented on Nov 22, 2026

    @Blind-Striker
    CollaboratorAuthor

    Moved to the roadmap board as a draft item. This is internal backlog rather than a request an outside user or contributor would act on, so it no longer lives in Issues. The history stays here.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions