Skip to content

Conversation

@nvartolomei
Copy link

@nvartolomei nvartolomei commented Jul 28, 2025

fix: Prevent hang when client disconnects under load

In Azurite, all operations are managed through concurrent operation
queues. A bug was identified where operations could hang indefinitely if
the client disconnected before the operation was processed.

This occurred because Azurite would attempt to attach event handlers to
the request's readable stream (body) after it had already been closed by
the client's disconnection. Since a closed stream emits no further
events (like 'data', 'close', or 'error'), the operation would never
complete, causing a permanent hang.

This fix addresses the issue by checking if the request stream is still
readable before attaching any event handlers. This ensures that we only
process requests that are still active, preventing the hang and allowing
the queues to continue processing other operations.

Thanks for contribution! Please go through following checklist before sending PR.

PR Branch Destination

  • For Azurite V3, please send PR to main branch.
  • For legacy Azurite V2, please send PR to legacy-dev branch.

Always Add Test Cases

Make sure test cases are added to cover the code change.

Add Change Log

Add change log for the code change in Upcoming Release section in ChangeLog.md.

Development Guideline

Please go to CONTRIBUTION.md for steps about setting up development environment and recommended Visual Studio Code extensions.

@nvartolomei nvartolomei marked this pull request as draft July 28, 2025 16:07
@nvartolomei

This comment was marked as outdated.

@nvartolomei

This comment was marked as resolved.

@blueww
Copy link
Member

blueww commented Aug 5, 2025

@nvartolomei
Thanks for the contribution!
It would be better if you could also add changelog.

@XiaoningLiu , @EmmaZhu,
Would you please help to review the PR?

…erationQueue processes the request

In Azurite, all operations are managed through concurrent operation
queues. A bug was identified where operations could hang indefinitely if
the client disconnected before the operation was processed.

This occurred because Azurite would attempt to attach event handlers to
the request's readable stream (body) after it had already been closed by
the client's disconnection. Since a closed stream emits no further
events (like 'data', 'close', or 'error'), the operation would never
complete, causing a permanent hang.

This fix addresses the issue by checking if the request stream is still
readable before attaching any event handlers. This ensures that we only
process requests that are still active, preventing the hang and allowing
the queues to continue processing other operations.
@rockwotj
Copy link

@EmmaZhu would be great to merge this!

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.

4 participants