Skip to content

Commit c70a93a

Browse files
alwxclaude
andcommitted
fix(ios): Resolve fetchViewHierarchy with nil on capture failure
When `captureViewHierarchy` returned nil the ObjC code still constructed an empty `NSMutableArray` and resolved with it. In JS, `[]` is truthy — the caller would treat the failure as a successful (empty) attachment. Bail out with `resolve(nil)` up front so the JS side sees the actual failure signal. Pre-existing since 2023; flagged by Seer while reviewing this PR. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 5cfce5e commit c70a93a

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

packages/core/ios/RNSentry.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,12 @@ - (void)handleShakeDetected
683683
{
684684
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
685685
NSData *rawViewHierarchy = [RNSentryInternal captureViewHierarchy];
686+
if (rawViewHierarchy == nil) {
687+
// Propagate the capture failure to JS instead of a truthy `[]`, which
688+
// would be treated as a successful (empty) attachment.
689+
resolve(nil);
690+
return;
691+
}
686692

687693
NSMutableArray *viewHierarchy = [NSMutableArray arrayWithCapacity:rawViewHierarchy.length];
688694
const char *bytes = (char *)[rawViewHierarchy bytes];

0 commit comments

Comments
 (0)