Skip to content

Conversation

@FabianMeiswinkel
Copy link
Member

@FabianMeiswinkel FabianMeiswinkel commented Nov 11, 2025

Description

This PR fixes a possible Netty-Buffer leak that can happen when timouts occur in Gateway mode. The problem was identified with the new test hardening enabling Netty Buffer leak detection in all CI pipeline tests.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copilot AI review requested due to automatic review settings November 11, 2025 18:42
Copilot finished reviewing on behalf of FabianMeiswinkel November 11, 2025 18:45
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 fixes a Netty buffer memory leak in Gateway mode caused by a race condition during timeout scenarios. The fix ensures proper cleanup of retained ByteBuf instances when operations are cancelled or fail.

Key Changes:

  • Added doOnDiscard operator to release ByteBuf instances when the reactive stream is cancelled/discarded
  • Wrapped response processing logic in try-catch block to ensure ByteBuf is released if unwrapping fails
  • Used safeRelease to handle potential race conditions between discard and error handlers

Copy link
Member

@xinlian12 xinlian12 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@FabianMeiswinkel FabianMeiswinkel merged commit b72cd7b into Azure:main Nov 11, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants