Skip to content

Multiple calls to getRandomValues #18606

@gedu

Description

@gedu

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react-native

SDK Version

10.15.0

Framework Version

@sentry/react-native": "7.2.0"

Link to Sentry event

No response

Reproduction Example/SDK Setup

Sentry.init({
  dsn: SENTRY_DSN,
  environment:
    __DEV__ || process.env.E2E_MODE === 'true' ? 'development' : 'production',
  release,
  dist,

  // Keep disabled to avoid attaching stacktraces to non-exception events (can affect event titles in UI).
  attachStacktrace: false,

  // Generic targets (no company/app domains).
  tracePropagationTargets: ['localhost'],

  // Keep the same behavior as the original wrapper.
  tracesSampleRate: 1,

  integrations: [
    routingInstrumentation,
    Sentry.hermesProfilingIntegration?.({ platformProfilers: false }),
    Sentry.breadcrumbsIntegration?.({
      dom: false,
      fetch: false,
      history: false,
      sentry: false,
      xhr: false,
      console: false,
    }),
    Sentry.reactNativeTracingIntegration?.({ idleTimeoutMs: 1500 }),
  ].filter(Boolean),

  // denyUrls: [...],
  // ignoreErrors: [...],
  // beforeSend: (event) => event,
  // beforeSendTransaction: (tx) => tx,
  // tracesSampler: (ctx) => 0.1,
  // maxBreadcrumbs: 50,
});

// Initial config needs to be done after Sentry.init is called.
setSentryConfig({
  tracesSampleRate: baseTransactionSampleRate,
  tracesSampleRateByName: {
    // Low importance transactions (generic example).
    'GET /example/low-importance-endpoint': baseTransactionSampleRate / 2,
  },
  sessionRateLimit: {
    maxDuplicatedEvents: process.env.E2E_MODE === 'true' || __DEV__ ? 1 : 10,
    totalMaxEvents: process.env.E2E_MODE === 'true' || __DEV__ ? 10 : 5_000,
  },
  identification: {
    domain: 'example.com',
  },
});

Steps to Reproduce

Making request in the app, found
node_modules/@sentry/core/build/esm/utils/tracing.js

/**
 * Create sentry-trace header from span context values.
 */
function generateSentryTraceHeader(
  traceId = generateTraceId(),
  spanId = generateSpanId(),
  sampled,
) {
  let sampledString = '';
  if (sampled !== undefined) {
    sampledString = sampled ? '-1' : '-0';
  }
  return `${traceId}-${spanId}${sampledString}`;
}

function generateTraceparentHeader(
  traceId = generateTraceId(),
  spanId = generateSpanId(),
  sampled,
) {
  return `00-${traceId}-${spanId}-${sampled ? '01' : '00'}`;
}

the generateTraceId and generateSpanId because are there as default the are being executed always, no matter if you call the function passing values.

Expected Result

calling the function generateSentryTraceHeader and generateTraceparentHeader, shouldn't generate extra calls to getRandomValues when generating a uuid4

Actual Result

calling the function generateSentryTraceHeader and generateTraceparentHeader, generate more than 90 calls to the getRandomValues to generate the uuid4

Additional Context

No response

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions