Skip to content

Commit

Permalink
fix(web-vitals): [v7] Check for undefined navigation entry (#11312)
Browse files Browse the repository at this point in the history
Backport of #11311
  • Loading branch information
AbhiPrasad committed Mar 28, 2024
1 parent 75b4361 commit 42b09c5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/tracing-internal/src/browser/metrics/index.ts
Expand Up @@ -32,7 +32,6 @@ import { _startChild, isMeasurementValue } from './utils';

import { createSpanEnvelope } from '@sentry/core';
import { getNavigationEntry } from '../web-vitals/lib/getNavigationEntry';
import type { TTFBMetric } from '../web-vitals/types/ttfb';

const MAX_INT_AS_BYTES = 2147483647;

Expand Down Expand Up @@ -674,7 +673,11 @@ function setResourceEntrySizeData(
* ttfb information is added via vendored web vitals library.
*/
function _addTtfbRequestTimeToMeasurements(_measurements: Measurements): void {
const navEntry = getNavigationEntry() as TTFBMetric['entries'][number];
const navEntry = getNavigationEntry();
if (!navEntry) {
return;
}

const { responseStart, requestStart } = navEntry;

if (requestStart <= responseStart) {
Expand Down

0 comments on commit 42b09c5

Please sign in to comment.