Skip to content

Conversation

@akja-bagja
Copy link

@akja-bagja akja-bagja commented May 28, 2025

In Instana Android agent version 6.0.23, there is an issue where requests are being duplicated. This occurs when any Exception happens during the execution of a network request, regardless of whether the request was modified by Instana itself. That is, if any interceptor generates an exception, the mechanism implemented in OkHttp3GlobalInterceptor initiates a repeat request.

  1. Technical Analysis of OkHttp3GlobalInterceptor
    Purpose: This interceptor is responsible for processing network requests, and its logic includes restarting requests when errors occur.

Trigger Logic: If any exception occurs during request execution, regardless of its source, the interceptor considers the request incorrectly executed and initiates a retry.
Consequences: A repeat request is sent even when the original request was not modified. This is not obvious to developers who may expect the logic of underlying interceptors to execute without fear of duplicate calls.
Disruption of Expected Behavior: Lower-level interceptors responsible for error handling may generate exceptions for incorrect HTTP codes or other issues. However, their exceptions automatically lead to request retries, which may not align with the application's logic.
Breaking the Processing Chain: Errors handled by lower layers are expected to be correctly propagated upward. But if an exception leads to a repeat request, this can disrupt internal error handling logic and cause duplicate actions.

Current Implementation Problem
The interceptor's current implementation has a catch-all exception handler that unconditionally performs a second request when any exception occurs:

My solution was to add a configurable flag in InstanaConfig.kt

  • When enabled, automatic retries will be performed when exceptions occur during HTTP requests.
  • When disabled, exceptions will propagate normally without retrying.
  • Default is false to prevent unexpected duplicate requests.

@akja-bagja akja-bagja requested a review from a team as a code owner May 28, 2025 01:00
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