Skip to content

Chunking @sentry/react results in “Multiple Sentry Session Replay instances are not supported” error #14915

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

Closed
3 tasks done
daraclare opened this issue Jan 6, 2025 · 2 comments

Comments

@daraclare
Copy link

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

^8.47.0

Framework Version

React 18.2

Link to Sentry event

https://viasat-c0.sentry.io/issues/6199709160/?environment=production&project=4506784165658624&referrer=project-issue-stream&statsPeriod=24h

Reproduction Example/SDK Setup

import React from "react";
import ReactDOM from "react-dom/client";
import {
  init,
  browserTracingIntegration,
  replayIntegration,
  captureConsoleIntegration,
} from "@sentry/react";
import App from "@/src/App.jsx";
import { getEnv } from "@/src/envUtils.js";
import packageProps from "@root/package.json";
 
const isDev = getEnv("MODE") !== "production";
 
init({
  release: `Ad Units: v${packageProps.version}`,
  environment: getEnv("MODE"),
  dsn: getEnv("VITE_SENTRY_DSN"),
  integrations: [
    browserTracingIntegration(),
    replayIntegration({
      maskAllText: false,
      blockAllMedia: false,
      maskAllInputs: true,
    }),
    captureConsoleIntegration({
      levels: ["error"],
    }),
  ],
 
  // Performance Monitoring
  tracesSampleRate: 1.0, //  Capture 100% of the transactions
  // Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
  tracePropagationTargets: ["localhost", /^\//],
  // Session Replay
  replaysSessionSampleRate: 0, // This sets the sample rate at 0%. You may want to change it to 100% while in development and then sample at a lower rate in production.
  replaysOnErrorSampleRate: isDev ? 0 : 0.5, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
});

Steps to Reproduce

  1. Build a vite app using React, and initialise Sentry as above in the main file (i.e. before the App component),
  2. Every works as expected, until you add chunking to the vite config and chunk sentry/react, see below:
export default () => {
  return defineConfig({
    plugins: [react()],
    build: {
      lib: {
        entry: resolve(__dirname, "src/main.jsx"),
        name: "adunits",
        fileName: "index",
        formats: ["es"],
      },
      rollupOptions: {
        output: {
          entryFileNames: "index.js",
          assetFileNames: "index.css",
          manualChunks: {
            sentryreact: ["@sentry/react"],
          },
        },
      },
    },
  });
};

Now the error “Multiple Sentry Session Replay instances are not supported” occurs in Sentry in production.

Expected Result

No error should occur

Actual Result

“Multiple Sentry Session Replay instances are not supported” error occurs

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 6, 2025
@github-actions github-actions bot added the Package: react Issues related to the Sentry React SDK label Jan 6, 2025
@chargome chargome added the Package: replay Issues related to the Sentry Replay SDK label Jan 7, 2025
@chargome
Copy link
Member

chargome commented Jan 7, 2025

Hey @daraclare thanks for reaching out!

That is just a wild guess but since replay is installed with a different package your config might mess up the setup.
Could you try updating your manualChunks to something like

function manualChunks(id) {
	if (id.includes('node_modules/@sentry')) { // or includes('@sentry') idk
		return 'sentry';
	}
}

and see if that helps?

@mydea mydea added the Replays label Apr 14, 2025 — with Linear
@getsantry getsantry bot moved this from Waiting for: Product Owner to Waiting for: Community in GitHub Issues with 👀 3 Apr 14, 2025
@stephanie-anderson stephanie-anderson removed the Package: react Issues related to the Sentry React SDK label Apr 16, 2025
@stephanie-anderson stephanie-anderson removed React Package: replay Issues related to the Sentry Replay SDK labels Apr 16, 2025
@mydea
Copy link
Member

mydea commented May 7, 2025

Why was this issue closed?

This issue hasn't been touched recently and no longer seems relevant.
Hence, we're closing it to maintain a clean and transparent backlog.

Please feel free to leave a comment if you think this issue should be reopened.

@mydea mydea closed this as not planned Won't fix, can't repro, duplicate, stale May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

4 participants