Skip to content

Reproduction for sentry-react-native#5561#16

Closed
antonis wants to merge 1 commit intomainfrom
repro/sentry-react-native-5561
Closed

Reproduction for sentry-react-native#5561#16
antonis wants to merge 1 commit intomainfrom
repro/sentry-react-native-5561

Conversation

@antonis
Copy link
Contributor

@antonis antonis commented Jan 28, 2026

Reproduction for sentry-react-native#5561

Issue: getsentry/sentry-react-native#5561

Summary

This reproduction successfully demonstrates the excessive getRandomValues calls issue reported in sentry-react-native#5561. The app shows that a single HTTP request triggers 62-93 calls to getRandomValues instead of the expected 2-5 calls.

Key Findings

Issue Reproduced: 62-93 getRandomValues calls per fetch request
Root Cause Identified: Only 1 unique call pattern executed 62 times (61 duplicates)
Location: @sentry/core tracing utilities

Root Cause Analysis

The investigation revealed that all 62 calls share the same stack trace, indicating the same code path is being executed repeatedly. The calls originate from:

  1. generateSentryTraceHeader() / generateTraceparentHeader() in @sentry/core/build/esm/utils/tracing.js
  2. These functions use default parameters traceId = generateTraceId() and spanId = generateSpanId()
  3. Functions are being called without passing ID values, triggering UUID generation each time
  4. Each UUID generation calls getRandomByte() via String.replace() callback

How to Run

See the README for detailed setup instructions.

cd sentry-react-native/5561
npm install
npx @react-native-community/cli init SentryReproApp --directory . --skip-install
cd ios && pod install && cd ..
npm run ios

The app includes instrumentation that displays:

  • Real-time counter of getRandomValues calls
  • Analysis showing unique vs duplicated call patterns
  • Detailed console logs with stack traces

Environment

  • React Native: 0.81.5
  • @sentry/react-native: 7.2.0
  • Tested on: iOS Simulator (iPhone 16 Pro)

🤖 Generated with Claude Code

Successfully reproduces excessive getRandomValues calls (~62-93 per request)
when making fetch requests with Sentry tracing enabled.

Root Cause Analysis:
- Issue confirmed in @sentry/core tracing utilities
- Only 1 unique call pattern, executed 62 times (61 duplicates)
- generateSentryTraceHeader/generateTraceparentHeader functions called
  repeatedly without passing traceId/spanId values, causing default
  parameters to generate new UUIDs each time
- All calls originate from getRandomByte during UUID generation via
  String.replace() callback

Expected: ~2-5 getRandomValues calls per request
Actual: ~62-93 getRandomValues calls per request

Confirmed working on:
- React Native 0.81.5
- @sentry/react-native 7.2.0
- iOS Simulator (iPhone 16 Pro)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

try {
// Make a simple HTTP request
const response = await fetch('https://httpbin.org/get');
const data = await response.json();
Copy link

Choose a reason for hiding this comment

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

Unused variable data from response parsing

Low Severity

The data variable is assigned from response.json() but never used anywhere in the code. This dead store adds unnecessary code and could confuse future maintainers about whether the parsed response data is needed. If the JSON parsing is intentional to simulate a complete request lifecycle, the result can be discarded without assignment, or the parsing can be removed entirely.

Fix in Cursor Fix in Web

Copy link
Contributor Author

@antonis antonis left a comment

Choose a reason for hiding this comment

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

Closing this repro as it served its purpose

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants