Skip to content

Optimize deduplication of HTTP requests #6187

Closed

Description

@antonis

Description

Following up on the implementation of #6132 we will need to investigate if a better/simpler way of deduplicating the HTTP requests is feasible

Context #6132 (review)

Activity

  1. linear-code commented on May 19, 2026

    @linear-code
  2. antonis commented on Jun 17, 2026

    @antonis
    ContributorAuthor

    Investigated the "better/simpler" angle. Summary of where this lands:

    Recap of the options (from #3045): (1) JS-only breadcrumbs — rejected, loses native-only requests; (2) native-only — rejected, bypasses beforeBreadcrumb; (3) mark JS requests + native interceptor drops the dup; (4) heuristic duplicate filtering — what shipped in #6132.

    Option 3 is the principled end-state but it's cross-SDK, not simpler. The duplication isn't iOS-only — it's produced by:

    • iOS: sentry-cocoa SentryNetworkTracker swizzling NSURLSession (always on).
    • Android: sentry-okhttp's interceptor/listener, auto-installed by the Sentry Android Gradle Plugin (autoInstallation defaults to on). RN networking runs on OkHttp, so JS requests get a native breadcrumb too.

    So option 3 needs the JS marking layer plus matching "skip if marker header present" logic in both sentry-cocoa and sentry-java/sentry-okhttp. Miss one and that platform regresses to duplicates. Open questions for a spike: marking all JS requests (today header injection is gated by tracePropagationTargets and only covers traced requests); marker header leaking to customer servers (no CORS preflight in RN, so no breakage, but ugly — stripping is impractical post-swizzle); and getting RN-specific marker handling accepted into two shared SDKs.

    The current heuristic's structural advantage is that it's one platform-agnostic function that dedups any native http breadcrumb regardless of source — cocoa swizzle, SAGP-injected OkHttp, a manually-added interceptor, or a future source. Option 3 only suppresses the sources whose interceptor we modify, so it's narrower in coverage unless every native HTTP path honors the marker.

    Recommendation: treat this as a deliberate cost/benefit call rather than a search for a simpler trick. Keep the heuristic unless its false-positive/negative rate proves problematic in the field; pursue option 3 only as a coordinated multi-SDK effort if we decide the determinism is worth it. Worth validating the JS "mark every request" hook in a spike first, since that's the main uncertainty.

  3. self-assigned this
    on Jun 17, 2026
  4. antonis commented on Jun 17, 2026

    @antonis
    ContributorAuthor

    Closing as won't do for now. Per the analysis above, Option 3 is the more principled approach but requires coordinated changes across three SDKs (RN + sentry-cocoa + sentry-java) and ends up narrower in coverage than the current platform-agnostic heuristic. The determinism benefit is real but marginal, and we have no field reports of the heuristic producing wrong results. Revisit if false positives/negatives show up in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions