Repository navigation
fix: capturing with a configureScope callback no longer re-runs BeforeBreadcrumb or re-syncs the scope to native SDKs - #5653
Merged
Conversation
Scope.Clone copied data through the public mutators, so every clone re-ran BeforeBreadcrumb and TagFilters and re-sent the whole scope to the scope observer. Clone now copies state directly. The temporary scope handed to configureScope in CaptureEvent and CaptureFeedback no longer syncs to the scope observer either, so per-event data stays off the native scope. Fixes #5647 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5653 +/- ##
==========================================
+ Coverage 74.94% 75.05% +0.11%
==========================================
Files 515 515
Lines 18975 18990 +15
Branches 3695 3692 -3
==========================================
+ Hits 14220 14253 +33
+ Misses 3875 3869 -6
+ Partials 880 868 -12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jamescrosswell
commented
Oct 4, 2026
Clone now populates the new scope with scope sync disabled, so Environment, User and Transaction can go through their setters. Only breadcrumbs and tags are still copied directly, to skip BeforeBreadcrumb and TagFilters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ric-oliv
reviewed
Oct 5, 2026
Clone_CopiesAllData now also covers OnEvaluating, SessionUpdate and the scope processors, and Clone_EveryFieldHandled fails when a Scope field is added without deciding whether Clone copies it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first PushScope in the Hub constructor used to send the root propagation context to the scope observer as a side effect of cloning. Cloning no longer syncs, so the Hub now does it explicitly, keeping native crashes on the same trace as managed errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ric-oliv
self-requested a review
October 6, 2026 11:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Scope.Clone()copied data into the new scope through the public mutators (AddBreadcrumb,SetTag,User,Environment, ...). Every clone therefore:BeforeBreadcrumbon breadcrumbs it had already processed. This affects every platform, not only scope sync: with a transforming callback,CaptureException(ex, s => ...)sentcrumb [scrubbed] [scrubbed]whereCaptureException(ex)sentcrumb [scrubbed]TagFiltersCaptureException(ex, configureScope), and in non-global mode on everyPushScopeClone()now fills in the new scope with scope sync turned off, and copies breadcrumbs and tags directly soBeforeBreadcrumbandTagFiltersdon't run again.Separately, the temporary scope handed to
configureScopeinCaptureEvent/CaptureFeedbackno longer syncs to the scope observer. That scope only exists for a single event, but tags, users and breadcrumbs set on it were synced to the native scope and stayed there, ending up on later native crashes.Notes for review
Huband the two*_ConfigureScope_ChangesNotSyncedtests.Scope.ScopeSyncEnabledflag. The ten observer calls inScopenow go through a single privateScopeObserveraccessor that checks it, instead of each checkingOptions.EnableScopeSync.PushScope()in theHubconstructor used to send the root trace to the scope observer as a side effect of cloning. TheHubconstructor now does that explicitly, so native crashes stay on the same trace as managed errors. Global mode (iOS/Android) never had this sync and is unchanged.SdkVersion.CopyTois shared byApplyandClone.Apply(Scope)is public and unchanged: applying one scope onto another still goes through the mutators.Closes #5647
🤖 Generated with Claude Code