Skip to content

fix(middleware): drain websocket session end streams - #3143

Merged
pimlock merged 3 commits into
mainfrom
fix-websocket-session-end/pimlock
Sep 2, 2026
Merged

fix(middleware): drain websocket session end streams#3143
pimlock merged 3 commits into
mainfrom
fix-websocket-session-end/pimlock

Conversation

@pimlock

@pimlock pimlock commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Prevent WebSocket middleware session-end notifications from being canceled with their bidirectional gRPC stream. The supervisor now half-closes the request side and briefly drains the response side before releasing the transport.

Related Issue

No issue required: localized lifecycle fix found while investigating the Rust test hang in #3085.

Changes

  • keep the tonic response stream alive while the terminal request leaves the local transport
  • use the same bounded close path for preflight exits, explicit session ends, disabled stages, and dropped sessions
  • bound the skip regression assertion so delivery failures report instead of hanging the test process
  • document the stream shutdown contract for middleware implementations

Before and after

sequenceDiagram
    participant S as Supervisor
    participant H as tonic / h2
    participant M as Middleware

    Note over S,M: Previous shutdown
    S->>H: Queue session_end
    S-xH: Drop request and response handles
    H--xM: RST_STREAM(CANCEL) may discard session_end

    Note over S,M: Graceful shutdown
    S->>H: Queue session_end
    S->>H: Drop request sender to half-close
    H->>M: Deliver session_end, then request EOF
    M-->>H: Finish response stream
    H-->>S: Drain completes or reaches the 10 ms bound
Loading

Testing

  • mise run pre-commit passes
  • cargo test --workspace --exclude openshell-server passes
  • cargo test -p openshell-server --features test-support passes
  • all 85 openshell-supervisor-middleware tests pass
  • all 66 supervisor-network WebSocket tests pass against h2 0.4.19
  • E2E tests added or updated, not applicable for this localized transport lifecycle fix

Checklist

  • Follows Conventional Commits
  • Commits are signed off for DCO

Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
@pimlock
pimlock added this pull request to the merge queue Sep 2, 2026
Merged via the queue into main with commit 6c3980d Sep 2, 2026
57 checks passed
@pimlock
pimlock deleted the fix-websocket-session-end/pimlock branch September 2, 2026 20:41
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.

2 participants