Skip to content

Reproduction for sentry-javascript#19580#29

Open
nicohrubec wants to merge 3 commits intomainfrom
repro/sentry-javascript-19580
Open

Reproduction for sentry-javascript#19580#29
nicohrubec wants to merge 3 commits intomainfrom
repro/sentry-javascript-19580

Conversation

@nicohrubec
Copy link
Member

Summary

  • Reproduces sentry-javascript#19580: reactRouterTracingIntegration produces [object Object] as transaction name when navigating with an object to prop
  • Minimal React Router v7 framework mode app with @sentry/react-router integration
  • Two links on the home page: one with a string to (works correctly) and one with an object to (shows the bug)

How to run

cd sentry-javascript/19580
export SENTRY_DSN=<your-dsn>
npm install
npm run dev

Click the object-based Link and observe the transaction name [object Object] in Sentry.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Client-side process.env unavailable in Vite bundle
    • Replaced process.env.SENTRY_DSN with import.meta.env.VITE_SENTRY_DSN in the client entrypoint and updated the repro instructions to use the Vite-prefixed variable.
  • ✅ Fixed: Generated .react-router/types files committed to repository
    • Removed the committed generated .react-router/types files and added sentry-javascript/19580/.gitignore with .react-router/ to keep them out of version control.

Create PR

Or push these changes by commenting:

@cursor push 137bc694e2
Preview (137bc694e2)
diff --git a/sentry-javascript/19580/.gitignore b/sentry-javascript/19580/.gitignore
new file mode 100644
--- /dev/null
+++ b/sentry-javascript/19580/.gitignore
@@ -1,0 +1 @@
+.react-router/

diff --git a/sentry-javascript/19580/.react-router/types/+future.ts b/sentry-javascript/19580/.react-router/types/+future.ts
deleted file mode 100644
--- a/sentry-javascript/19580/.react-router/types/+future.ts
+++ /dev/null
@@ -1,9 +1,0 @@
-// Generated by React Router
-
-import "react-router";
-
-declare module "react-router" {
-  interface Future {
-    v8_middleware: false
-  }
-}
\ No newline at end of file

diff --git a/sentry-javascript/19580/.react-router/types/+routes.ts b/sentry-javascript/19580/.react-router/types/+routes.ts
deleted file mode 100644
--- a/sentry-javascript/19580/.react-router/types/+routes.ts
+++ /dev/null
@@ -1,43 +1,0 @@
-// Generated by React Router
-
-import "react-router"
-
-declare module "react-router" {
-  interface Register {
-    pages: Pages
-    routeFiles: RouteFiles
-    routeModules: RouteModules
-  }
-}
-
-type Pages = {
-  "/": {
-    params: {};
-  };
-  "/items/:id": {
-    params: {
-      "id": string;
-    };
-  };
-};
-
-type RouteFiles = {
-  "root.tsx": {
-    id: "root";
-    page: "/" | "/items/:id";
-  };
-  "routes/home.tsx": {
-    id: "routes/home";
-    page: "/";
-  };
-  "routes/items.$id.tsx": {
-    id: "routes/items.$id";
-    page: "/items/:id";
-  };
-};
-
-type RouteModules = {
-  "root": typeof import("./app/root.tsx");
-  "routes/home": typeof import("./app/routes/home.tsx");
-  "routes/items.$id": typeof import("./app/routes/items.$id.tsx");
-};
\ No newline at end of file

diff --git a/sentry-javascript/19580/.react-router/types/+server-build.d.ts b/sentry-javascript/19580/.react-router/types/+server-build.d.ts
deleted file mode 100644
--- a/sentry-javascript/19580/.react-router/types/+server-build.d.ts
+++ /dev/null
@@ -1,18 +1,0 @@
-// Generated by React Router
-
-declare module "virtual:react-router/server-build" {
-  import { ServerBuild } from "react-router";
-  export const assets: ServerBuild["assets"];
-  export const assetsBuildDirectory: ServerBuild["assetsBuildDirectory"];
-  export const basename: ServerBuild["basename"];
-  export const entry: ServerBuild["entry"];
-  export const future: ServerBuild["future"];
-  export const isSpaMode: ServerBuild["isSpaMode"];
-  export const prerender: ServerBuild["prerender"];
-  export const publicPath: ServerBuild["publicPath"];
-  export const routeDiscovery: ServerBuild["routeDiscovery"];
-  export const routes: ServerBuild["routes"];
-  export const ssr: ServerBuild["ssr"];
-  export const allowedActionOrigins: ServerBuild["allowedActionOrigins"];
-  export const unstable_getCriticalCss: ServerBuild["unstable_getCriticalCss"];
-}
\ No newline at end of file

diff --git a/sentry-javascript/19580/.react-router/types/app/+types/root.ts b/sentry-javascript/19580/.react-router/types/app/+types/root.ts
deleted file mode 100644
--- a/sentry-javascript/19580/.react-router/types/app/+types/root.ts
+++ /dev/null
@@ -1,59 +1,0 @@
-// Generated by React Router
-
-import type { GetInfo, GetAnnotations } from "react-router/internal";
-
-type Module = typeof import("../root.js")
-
-type Info = GetInfo<{
-  file: "root.tsx",
-  module: Module
-}>
-
-type Matches = [{
-  id: "root";
-  module: typeof import("../root.js");
-}];
-
-type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }, false>;
-
-export namespace Route {
-  // links
-  export type LinkDescriptors = Annotations["LinkDescriptors"];
-  export type LinksFunction = Annotations["LinksFunction"];
-
-  // meta
-  export type MetaArgs = Annotations["MetaArgs"];
-  export type MetaDescriptors = Annotations["MetaDescriptors"];
-  export type MetaFunction = Annotations["MetaFunction"];
-
-  // headers
-  export type HeadersArgs = Annotations["HeadersArgs"];
-  export type HeadersFunction = Annotations["HeadersFunction"];
-
-  // middleware
-  export type MiddlewareFunction = Annotations["MiddlewareFunction"];
-
-  // clientMiddleware
-  export type ClientMiddlewareFunction = Annotations["ClientMiddlewareFunction"];
-
-  // loader
-  export type LoaderArgs = Annotations["LoaderArgs"];
-
-  // clientLoader
-  export type ClientLoaderArgs = Annotations["ClientLoaderArgs"];
-
-  // action
-  export type ActionArgs = Annotations["ActionArgs"];
-
-  // clientAction
-  export type ClientActionArgs = Annotations["ClientActionArgs"];
-
-  // HydrateFallback
-  export type HydrateFallbackProps = Annotations["HydrateFallbackProps"];
-
-  // Component
-  export type ComponentProps = Annotations["ComponentProps"];
-
-  // ErrorBoundary
-  export type ErrorBoundaryProps = Annotations["ErrorBoundaryProps"];
-}
\ No newline at end of file

diff --git a/sentry-javascript/19580/.react-router/types/app/routes/+types/home.ts b/sentry-javascript/19580/.react-router/types/app/routes/+types/home.ts
deleted file mode 100644
--- a/sentry-javascript/19580/.react-router/types/app/routes/+types/home.ts
+++ /dev/null
@@ -1,62 +1,0 @@
-// Generated by React Router
-
-import type { GetInfo, GetAnnotations } from "react-router/internal";
-
-type Module = typeof import("../home.js")
-
-type Info = GetInfo<{
-  file: "routes/home.tsx",
-  module: Module
-}>
-
-type Matches = [{
-  id: "root";
-  module: typeof import("../../root.js");
-}, {
-  id: "routes/home";
-  module: typeof import("../home.js");
-}];
-
-type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }, false>;
-
-export namespace Route {
-  // links
-  export type LinkDescriptors = Annotations["LinkDescriptors"];
-  export type LinksFunction = Annotations["LinksFunction"];
-
-  // meta
-  export type MetaArgs = Annotations["MetaArgs"];
-  export type MetaDescriptors = Annotations["MetaDescriptors"];
-  export type MetaFunction = Annotations["MetaFunction"];
-
-  // headers
-  export type HeadersArgs = Annotations["HeadersArgs"];
-  export type HeadersFunction = Annotations["HeadersFunction"];
-
-  // middleware
-  export type MiddlewareFunction = Annotations["MiddlewareFunction"];
-
-  // clientMiddleware
-  export type ClientMiddlewareFunction = Annotations["ClientMiddlewareFunction"];
-
-  // loader
-  export type LoaderArgs = Annotations["LoaderArgs"];
-
-  // clientLoader
-  export type ClientLoaderArgs = Annotations["ClientLoaderArgs"];
-
-  // action
-  export type ActionArgs = Annotations["ActionArgs"];
-
-  // clientAction
-  export type ClientActionArgs = Annotations["ClientActionArgs"];
-
-  // HydrateFallback
-  export type HydrateFallbackProps = Annotations["HydrateFallbackProps"];
-
-  // Component
-  export type ComponentProps = Annotations["ComponentProps"];
-
-  // ErrorBoundary
-  export type ErrorBoundaryProps = Annotations["ErrorBoundaryProps"];
-}
\ No newline at end of file

diff --git a/sentry-javascript/19580/.react-router/types/app/routes/+types/items.$id.ts b/sentry-javascript/19580/.react-router/types/app/routes/+types/items.$id.ts
deleted file mode 100644
--- a/sentry-javascript/19580/.react-router/types/app/routes/+types/items.$id.ts
+++ /dev/null
@@ -1,62 +1,0 @@
-// Generated by React Router
-
-import type { GetInfo, GetAnnotations } from "react-router/internal";
-
-type Module = typeof import("../items.$id.js")
-
-type Info = GetInfo<{
-  file: "routes/items.$id.tsx",
-  module: Module
-}>
-
-type Matches = [{
-  id: "root";
-  module: typeof import("../../root.js");
-}, {
-  id: "routes/items.$id";
-  module: typeof import("../items.$id.js");
-}];
-
-type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }, false>;
-
-export namespace Route {
-  // links
-  export type LinkDescriptors = Annotations["LinkDescriptors"];
-  export type LinksFunction = Annotations["LinksFunction"];
-
-  // meta
-  export type MetaArgs = Annotations["MetaArgs"];
-  export type MetaDescriptors = Annotations["MetaDescriptors"];
-  export type MetaFunction = Annotations["MetaFunction"];
-
-  // headers
-  export type HeadersArgs = Annotations["HeadersArgs"];
-  export type HeadersFunction = Annotations["HeadersFunction"];
-
-  // middleware
-  export type MiddlewareFunction = Annotations["MiddlewareFunction"];
-
-  // clientMiddleware
-  export type ClientMiddlewareFunction = Annotations["ClientMiddlewareFunction"];
-
-  // loader
-  export type LoaderArgs = Annotations["LoaderArgs"];
-
-  // clientLoader
-  export type ClientLoaderArgs = Annotations["ClientLoaderArgs"];
-
-  // action
-  export type ActionArgs = Annotations["ActionArgs"];
-
-  // clientAction
-  export type ClientActionArgs = Annotations["ClientActionArgs"];
-
-  // HydrateFallback
-  export type HydrateFallbackProps = Annotations["HydrateFallbackProps"];
-
-  // Component
-  export type ComponentProps = Annotations["ComponentProps"];
-
-  // ErrorBoundary
-  export type ErrorBoundaryProps = Annotations["ErrorBoundaryProps"];
-}
\ No newline at end of file

diff --git a/sentry-javascript/19580/README.md b/sentry-javascript/19580/README.md
--- a/sentry-javascript/19580/README.md
+++ b/sentry-javascript/19580/README.md
@@ -16,7 +16,7 @@
 
 1. Set your Sentry DSN:
    ```bash
-   export SENTRY_DSN=<your-dsn>
+   export VITE_SENTRY_DSN=<your-dsn>
    ```
 
 2. Install dependencies:

diff --git a/sentry-javascript/19580/app/entry.client.tsx b/sentry-javascript/19580/app/entry.client.tsx
--- a/sentry-javascript/19580/app/entry.client.tsx
+++ b/sentry-javascript/19580/app/entry.client.tsx
@@ -4,7 +4,7 @@
 import { HydratedRouter } from "react-router/dom";
 
 Sentry.init({
-  dsn: process.env.SENTRY_DSN || "",
+  dsn: import.meta.env.VITE_SENTRY_DSN || "",
   integrations: [Sentry.browserTracingIntegration()],
   tracesSampleRate: 1.0,
   debug: true, // Enable debug to see transaction names in console
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

import { HydratedRouter } from "react-router/dom";

Sentry.init({
dsn: process.env.SENTRY_DSN || "",
Copy link

Choose a reason for hiding this comment

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

Client-side process.env unavailable in Vite bundle

High Severity

process.env.SENTRY_DSN is not available in Vite client-side bundles. Vite only exposes env variables prefixed with VITE_ via import.meta.env, and does not define a global process object in the browser. This will cause a ReferenceError: process is not defined at runtime, preventing Sentry from initializing on the client — which means the browserTracingIntegration never activates and the reproduction cannot actually demonstrate the [object Object] transaction name bug it was created for.

Fix in Cursor Fix in Web

interface Future {
v8_middleware: false
}
} No newline at end of file
Copy link

Choose a reason for hiding this comment

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

Generated .react-router/types files committed to repository

Low Severity

The .react-router/types/ directory contains auto-generated files (marked // Generated by React Router) that React Router's documentation explicitly says to add to .gitignore. These files are regenerated on every dev/build run and aren't meant to be version-controlled. A .gitignore file with .react-router/ is missing from the reproduction.

Additional Locations (2)

Fix in Cursor Fix in Web

nicohrubec and others added 2 commits March 2, 2026 13:27
- Use reactRouterTracingIntegration() instead of browserTracingIntegration()
- Use createSentryHandleRequest/createSentryHandleError in entry.server.tsx
- Add instrument.server.mjs with NODE_OPTIONS for server-side init

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant