Skip to content

Wait for the queue to complete before completing the request.#955

Merged
mayuki merged 2 commits intomainfrom
feature/FixDisposeBeforeHubConsumingQueueCompletion
Jun 25, 2025
Merged

Wait for the queue to complete before completing the request.#955
mayuki merged 2 commits intomainfrom
feature/FixDisposeBeforeHubConsumingQueueCompletion

Conversation

@mayuki
Copy link
Member

@mayuki mayuki commented Jun 24, 2025

This PR fixes an issue where ASP.NET Core requests would complete first when a client disconnected while there were Hub method queues consuming or waiting.

Ensures that the request queue is fully consumed before disconnecting a HTTP connection.
@mayuki mayuki requested a review from Copilot June 24, 2025 06:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that ASP.NET Core requests do not complete prematurely by waiting for the Hub method queue to be fully consumed before completing the request.

  • Changes in test files update log collections from List to ConcurrentBag for thread safety.
  • A new test verifies proper queue consumption and disconnection behavior in StreamingHub.
  • The StreamingHub implementation is updated to await the consumption of the request queue before invoking the disconnection logic.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/MagicOnion.Server.Tests/UnaryServiceTest.cs Changes logs collection type to ConcurrentBag for thread safety.
tests/MagicOnion.Server.Tests/StreamingHubDisconnectionTest.cs New test added to assess consumer behavior during disconnection.
tests/MagicOnion.Server.InternalTesting/MagicOnionApplicationFactory.cs Updates logs property type to ConcurrentBag for consistency.
src/MagicOnion.Server/Hubs/StreamingHub.cs Introduces waiting for the request queue consumption before completing a disconnection.

@mayuki mayuki merged commit 40de76c into main Jun 25, 2025
9 of 10 checks passed
@mayuki mayuki deleted the feature/FixDisposeBeforeHubConsumingQueueCompletion branch June 25, 2025 06:22
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