Skip to content

Commit 415d43f

Browse files
committed
Remove isLikelyLazyRoute
1 parent 385d041 commit 415d43f

File tree

4 files changed

+67
-277
lines changed

4 files changed

+67
-277
lines changed

packages/react/src/reactrouter-compat-utils/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export {
2020
resolveRouteNameAndSource,
2121
getNormalizedName,
2222
initializeRouterUtils,
23-
isLikelyLazyRouteContext,
2423
locationIsInsideDescendantRoute,
2524
prefixWithSlash,
2625
rebuildRoutePathFromAllRoutes,

packages/react/src/reactrouter-compat-utils/instrumentation.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import { checkRouteForAsyncHandler } from './lazy-routes';
4444
import {
4545
getNormalizedName,
4646
initializeRouterUtils,
47-
isLikelyLazyRouteContext,
4847
locationIsInsideDescendantRoute,
4948
prefixWithSlash,
5049
rebuildRoutePathFromAllRoutes,
@@ -577,16 +576,13 @@ export function handleNavigation(opts: {
577576
basename,
578577
);
579578

580-
// Check if this might be a lazy route context
581-
const isLazyRouteContext = isLikelyLazyRouteContext(allRoutes || routes, location);
582-
583579
const activeSpan = getActiveSpan();
584580
const spanJson = activeSpan && spanToJSON(activeSpan);
585581
const isAlreadyInNavigationSpan = spanJson?.op === 'navigation';
586582

587583
// Cross usage can result in multiple navigation spans being created without this check
588584
if (!isAlreadyInNavigationSpan) {
589-
createNewNavigationSpan(client, name, source, version, isLazyRouteContext);
585+
createNewNavigationSpan(client, name, source, version);
590586
}
591587
}
592588
}
@@ -739,7 +735,6 @@ export function createNewNavigationSpan(
739735
name: string,
740736
source: TransactionSource,
741737
version: string,
742-
isLikelyLazyRoute: boolean,
743738
): void {
744739
const newSpan = startBrowserTracingNavigationSpan(client, {
745740
name,
@@ -750,8 +745,7 @@ export function createNewNavigationSpan(
750745
},
751746
});
752747

753-
// For lazy routes, don't mark as named yet so it can be updated later when the route loads
754-
if (!isLikelyLazyRoute && newSpan) {
748+
if (newSpan) {
755749
addNonEnumerableProperty(
756750
newSpan as { __sentry_navigation_name_set__?: boolean },
757751
'__sentry_navigation_name_set__',

packages/react/src/reactrouter-compat-utils/utils.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,6 @@ export function initializeRouterUtils(matchRoutes: MatchRoutes, stripBasename: b
1414
_stripBasename = stripBasename;
1515
}
1616

17-
/**
18-
* Checks if the given routes or location context suggests this might be a lazy route scenario.
19-
* This helps determine if we should delay marking navigation spans as "named" to allow for updates
20-
* when lazy routes are loaded.
21-
*/
22-
export function isLikelyLazyRouteContext(routes: RouteObject[], location: Location): boolean {
23-
// Check if any route in the current match has lazy properties
24-
const hasLazyRoute = routes.some(route => {
25-
return (
26-
// React Router lazy() route
27-
route.lazy ||
28-
// Route with async handlers that might load child routes
29-
(route.handle &&
30-
typeof route.handle === 'object' &&
31-
Object.values(route.handle).some(handler => typeof handler === 'function'))
32-
);
33-
});
34-
35-
if (hasLazyRoute) {
36-
return true;
37-
}
38-
39-
// Check if current route is unmatched, which might indicate a lazy route that hasn't loaded yet
40-
const currentMatches = _matchRoutes(routes, location);
41-
if (!currentMatches || currentMatches.length === 0) {
42-
return true;
43-
}
44-
45-
return false;
46-
}
47-
4817
// Helper functions
4918
function pickPath(match: RouteMatch): string {
5019
return trimWildcard(match.route.path || '');

0 commit comments

Comments
 (0)