Skip to content

Integration with React Router v6 under performs when data loaders are used #17336

@serchavalos

Description

@serchavalos

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react

SDK Version

10.1.0

Framework Version

18.3.1

Link to Sentry event

No response

Reproduction Example/SDK Setup

Hello! 👋

My application is using the following setup with Sentry's SDK and its integration with React Router

import { createHashRouter } from 'react-router-dom'; // @v6.29.0

... 

// https://docs.sentry.io/platforms/javascript/guides/react/features/react-router/#usage-with-react-router-64-data-api
const sentryCreateHashRouter = Sentry.wrapCreateBrowserRouterV6(createHashRouter);

const router = sentryCreateHashRouter(
[
    {
      path: ALBUM.path,
      element: <AlbumView />,
     }
  ...
],
{
  basename: '/',
  future: {
    v7_relativeSplatPath: true,
    v7_startTransition: true,
  },
});

Steps to Reproduce

  1. I updated the route to use a feature from React router called data loaders (read more) with the following code
  {
    path: ALBUM.path,
    element: <AlbumView />,
+   loader: () =>
+     Promise.resolve({
+       album: {
+         id: '123',
+         name: 'Album Name',
+         artist: 'Artist Name',
+       },
+     }),
  },
  1. Then I measured the performance using DevTools

Expected Result

Since the data loader is not doing much, I was expecting the performance overhead to be mininum

Actual Result

I noticed a 10x increased in the flamewar for the function startBrowserTracingNavigationSpan

Before:
Image

After:
Image

This overhead goes away after I remove the wrapper Sentry.wrapCreateBrowserRouterV6. There is a difference between using and not using data loaders but it's minimum.

Thanks in advance for looking into this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions