Skip to content

refactor: Move session stop reason creation into Session constructor - #377

Merged
minghuaw merged 7 commits into
mainfrom
fix/stop-reason-propagation
Aug 17, 2026
Merged

refactor: Move session stop reason creation into Session constructor#377
minghuaw merged 7 commits into
mainfrom
fix/stop-reason-propagation

Conversation

@minghuaw

Copy link
Copy Markdown
Owner

No description provided.

Record the session stop reason before the engine closes the link channels
when ending, and derive ConnectionClosed when the session exits because the
connection stopped before its stop reason was recorded. Add client-side
integration tests covering send/recv/attach surfacing the stop reason on
connection stop and session end.
…eason)

Move the connection stop-reason cell onto the Connection object (shared with
the session, handle, and links, mirroring the session cell) and carry the
reason in ConnectionStopped(ConnectionStopReason) on the session error types,
following the SessionStopped pattern. AllocSessionError::IllegalState is split
into ConnectionNotOpened (not yet opened) and ConnectionStopped (closing or
closed). The session engine records the connection stop in its outcome, derives
the session stop reason from it, and sanitizes it at the boundary so the
session handle still ends cleanly when the connection stops first.
…ardown

SessionStopReason and ConnectionStopReason now distinguish a local from a
remote-originated stop (EndedWithError/ClosedWithError vs RemoteEnded/
RemoteClosedWithError), with the session reason embedding the connection
reason via ConnectionStopped(ConnectionStopReason). The local close-with-error
is recorded in the connection cell so links observe it regardless of how the
peer responds.

Fix two pre-existing teardown bugs surfaced by the new tests: the close
exchange drained buffered session frames while the guard only allowed the
Opened state, failing the close with IllegalState; and frames arriving in the
Discarding state were not discarded per AMQP 2.4.6, poisoning the close
outcome.

Add origin-differentiation tests (local/remote end and close with error) and
clean-teardown tests asserting that local end/close with an error stays clean
on the session/connection handle.
Signed-off-by: minghuaw <michael.wu1107@gmail.com>
@minghuaw
minghuaw merged commit fc169e0 into main Aug 17, 2026
3 checks passed
@minghuaw
minghuaw deleted the fix/stop-reason-propagation branch August 17, 2026 02:50
@minghuaw minghuaw mentioned this pull request Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant