Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(v8/react): Add support for React Router sub-routes from handle (#17277) #17433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
onurtemizkan wants to merge 3 commits into v8
base: v8
Choose a base branch
Loading
from onur/backport/lazy-routes-fix-to-v8

Conversation

Copy link
Collaborator

@onurtemizkan onurtemizkan commented Aug 20, 2025
edited
Loading

Backports #17277 and (the fix apart from the refactor at #17438) to v8

@onurtemizkan onurtemizkan marked this pull request as ready for review August 21, 2025 07:57
Comment on lines +132 to +139
function processResolvedRoutes(resolvedRoutes: RouteObject[], parentRoute?: RouteObject): void {
resolvedRoutes.forEach(child => {
allRoutes.add(child);
// Only check for async handlers if the feature is enabled
if (_enableAsyncRouteHandlers) {
checkRouteForAsyncHandler(child);
}
});
Copy link

@seer-by-sentry seer-by-sentry bot Aug 21, 2025

Choose a reason for hiding this comment

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

Potential bug: The processResolvedRoutes function lacks cycle detection, which can cause infinite recursion and a stack overflow if a route handler returns a circular reference.
  • Description: The processResolvedRoutes function iterates through resolved routes to check for async handlers. However, it lacks a check to see if a route has already been processed. If an async route handler's result contains a circular reference (e.g., a route that is an ancestor in the routing tree), the function will enter an infinite recursion loop (processResolvedRoutes -> checkRouteForAsyncHandler -> handleAsyncHandlerResult -> processResolvedRoutes). This leads to a stack overflow, crashing the application.

  • Suggested fix: Add a guard within the forEach loop in processResolvedRoutes to check if a route has already been processed before calling checkRouteForAsyncHandler. This can be done by checking if (!allRoutes.has(child)), mirroring the protective logic found in getChildRoutesRecursively.
    severity: 0.85, confidence: 0.9

Did we get this right? 👍 / 👎 to inform future reviews.

Comment on lines +191 to +196
for (const key of Object.keys(route.handle)) {
const maybeFn = route.handle[key];
if (typeof maybeFn === 'function' && !(maybeFn as { __sentry_proxied__?: boolean }).__sentry_proxied__) {
route.handle[key] = createAsyncHandlerProxy(maybeFn, route, key);
}
}
Copy link

@seer-by-sentry seer-by-sentry bot Aug 21, 2025

Choose a reason for hiding this comment

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

Potential bug: The checkRouteForAsyncHandler function proxies all functions in a route's handle, not just async loaders, causing significant performance overhead due to a logical flaw.
  • Description: The checkRouteForAsyncHandler function indiscriminately proxies every function found within a route's handle object. The handle object is often used for various purposes, including synchronous utility functions or metadata generators, not just the intended async route loaders. Every call to any of these proxied functions incurs unnecessary overhead from the proxy's apply trap and the subsequent call to handleAsyncHandlerResult. Because this logic is applied recursively to the entire route tree, it can cause significant performance degradation in applications with complex routing.

  • Suggested fix: Refine the logic in checkRouteForAsyncHandler to only proxy functions that are intended to be async route handlers. This could be achieved by checking for a specific naming convention for the handler key or introducing a mechanism to opt-in specific functions for proxying, rather than proxying all functions by default.
    severity: 0.7, confidence: 0.95

Did we get this right? 👍 / 👎 to inform future reviews.

@onurtemizkan onurtemizkan force-pushed the onur/backport/lazy-routes-fix-to-v8 branch from f8450d2 to 0e2892b Compare September 1, 2025 21:50
Copy link
Collaborator Author

@mydea, @chargome - I also added the fix inside #17438 here. The CI is not picking up this PR, though.

Copy link
Member

mydea commented Sep 2, 2025

v8 is currently not ship-able, because it still uses ubuntu-20.04 runners 😭 need to "fix" that first... basically the same as #17083 for v8 branch

onurtemizkan reacted with thumbs up emoji

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

@seer-by-sentry seer-by-sentry[bot] seer-by-sentry[bot] left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /