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.32.1
Framework Version
"react": "^18.2.0",
Link to Sentry event
No response
Reproduction Example/SDK Setup
import * as Sentry from '@sentry/react';
Sentry.init({
dsn: process.env.REACT_APP_SENTRY_DSN, // this is correct, I have checked
environment: process.env.NODE_ENV || "development",
sendDefaultPii: true,
tracesSampleRate: 1.0,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration({
maskAllText: false,
blockAllMedia: false,
}),
Sentry.httpClientIntegration({
failedRequestStatusCodes: [[400, 599]],
}),
Sentry.feedbackIntegration({
colorScheme: "system",
autoInject: false,
}),
],
enableLogs: true,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});
Steps to Reproduce
- Install Sentry package ("@sentry/react": "^10.32.1",)
- Call Sentry.init(config) with basic configuration mentioned in the docs
- Optional (add ErrorBoundary component) at the top level
Expected Result
Sentry should work fine
Actual Result
Sentry is not working and I am getting this error in the browser console
client.js:112 Uncaught TypeError: Cannot read properties of undefined (reading 'id')
at applyDefaultOptions (client.js:112:1)
at new BrowserClient (client.js:22:1)
at initAndBind (sdk.js:32:1)
at init (sdk.js:108:1)
at Module.init (sdk.js:15:1)
at ./client.js (client.js:12:1)
at __webpack_require__ (bootstrap:24:1)
at startup:6:1
at startup:6:1
If I click applyDefaultOptions
function applyDefaultOptions(optionsArg) {
return {
release:
typeof __SENTRY_RELEASE__ === 'string' // This allows build tooling to find-and-replace __SENTRY_RELEASE__ to inject a release value
? __SENTRY_RELEASE__
: WINDOW.SENTRY_RELEASE?.id, , // This supports the variable that sentry-webpack-plugin injects // <---- this is the actual line
sendClientReports: true,
// We default this to true, as it is the safer scenario
parentSpanIsAlwaysRootSpan: true,
...optionsArg,
};
}
Additional Context
I have tried everything, debugging on my own, playing with configuration, google search, asking chatgpt, claude, and cursor. Maybe I am missing something but I can't figure out. Here is the report generated by cursor
Report
Sentry initialization fails with TypeError: Cannot read properties of undefined (reading 'id') when calling Sentry.init() with any configuration, including minimal configurations. The error occurs in Sentry's internal applyDefaultOptions function during BrowserClient initialization.
Environment
- Package:
@sentry/react
- Version:
10.32.1
- React Version:
18.2.0
- Node Version:
>=16.13.0
- Build Tool: Webpack 5.66.0
Error Details
Error Message
TypeError: Cannot read properties of undefined (reading 'id')
at applyDefaultOptions (client.js:112:1)
at new BrowserClient (client.js:22:1)
at initAndBind (sdk.js:32:1)
at init (sdk.js:108:1)
at Module.init (sdk.js:15:1)
at ./client.js (client.js:18:1)
Impact
The application fails to load because Sentry initialization throws an uncaught error before React can render, completely blocking the application startup.
Steps to Reproduce
- Install
@sentry/react@10.32.1
- Import Sentry:
import * as Sentry from '@sentry/react'
- Call
Sentry.init() with any of the following configurations:
Minimal Configuration (Fails)
Sentry.init({
dsn: 'https://your-dsn@sentry.io/project-id'
});
With Empty Integrations (Fails)
Sentry.init({
dsn: 'https://your-dsn@sentry.io/project-id',
integrations: []
});
With Default Integrations (Fails)
Sentry.init({
dsn: 'https://your-dsn@sentry.io/project-id',
integrations: Sentry.getDefaultIntegrations()
});
With Explicit Transport/StackParser (Fails)
Sentry.init({
dsn: 'https://your-dsn@sentry.io/project-id',
transport: Sentry.makeFetchTransport,
stackParser: Sentry.defaultStackParser,
integrations: Sentry.getDefaultIntegrations()
});
Full Configuration (Fails)
Sentry.init({
dsn: 'https://your-dsn@sentry.io/project-id',
environment: 'development',
sendDefaultPii: true,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration(),
Sentry.httpClientIntegration(),
Sentry.feedbackIntegration()
],
tracesSampleRate: 1.0,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0
});
Result: All configurations fail with the same error.
Expected Behavior
Sentry should initialize successfully with any valid configuration, allowing the application to continue loading.
Actual Behavior
Sentry initialization throws TypeError: Cannot read properties of undefined (reading 'id') in the applyDefaultOptions function, preventing the application from loading.
Debugging Evidence
Verified Working Conditions
- ✅ DSN is correctly formatted (verified:
dsnType: 'string', dsnLength: 95)
- ✅ Window object exists (
windowExists: true)
- ✅ Sentry module is properly loaded (
sentryExists: true, sentryInitExists: true)
- ✅ All expected Sentry functions are available (
browserTracingIntegration, replayIntegration, makeFetchTransport, defaultStackParser, etc.)
- ✅ Webpack DefinePlugin correctly injects environment variables
- ✅ Default integrations function returns 9 integrations correctly
What We Tried
- Minimal config with only
dsn - ❌ Failed
- Empty
integrations: [] array - ❌ Failed
- Using
getDefaultIntegrations() - ❌ Failed
- Explicit
transport and stackParser - ❌ Failed
- Single integration (
browserTracingIntegration) - ❌ Failed
- Different environment variables - ❌ Failed
- Monkey-patched
Sentry.init to inspect options - All options correctly passed, error occurs in internal code
Workaround
Downgrading to @sentry/react@^8.55.0 resolves the issue. The same configuration works correctly with v8.
Code Example
import * as Sentry from '@sentry/react';
// This fails with the error
Sentry.init({
dsn: 'https://fa64da5aba4c69be09dabb60ccb6ff89@o4510507237965824.ingest.us.sentry.io/4510625104396288'
});
Additional Context
- The error occurs regardless of configuration options provided
- The error is consistent across different webpack build configurations (dev, staging, production)
- The issue appears to be in Sentry's internal initialization logic, not in user-provided configuration
- The same code works correctly with
@sentry/react@^8.55.0
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
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.32.1
Framework Version
"react": "^18.2.0",
Link to Sentry event
No response
Reproduction Example/SDK Setup
import * as Sentry from '@sentry/react';
Sentry.init({
dsn: process.env.REACT_APP_SENTRY_DSN, // this is correct, I have checked
environment: process.env.NODE_ENV || "development",
sendDefaultPii: true,
tracesSampleRate: 1.0,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration({
maskAllText: false,
blockAllMedia: false,
}),
Sentry.httpClientIntegration({
failedRequestStatusCodes: [[400, 599]],
}),
Sentry.feedbackIntegration({
colorScheme: "system",
autoInject: false,
}),
],
enableLogs: true,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});
Steps to Reproduce
Expected Result
Sentry should work fine
Actual Result
Sentry is not working and I am getting this error in the browser console
If I click applyDefaultOptions
Additional Context
I have tried everything, debugging on my own, playing with configuration, google search, asking chatgpt, claude, and cursor. Maybe I am missing something but I can't figure out. Here is the report generated by cursor
Report
Sentry initialization fails with
TypeError: Cannot read properties of undefined (reading 'id')when callingSentry.init()with any configuration, including minimal configurations. The error occurs in Sentry's internalapplyDefaultOptionsfunction duringBrowserClientinitialization.Environment
@sentry/react10.32.118.2.0>=16.13.0Error Details
Error Message
Impact
The application fails to load because Sentry initialization throws an uncaught error before React can render, completely blocking the application startup.
Steps to Reproduce
@sentry/react@10.32.1import * as Sentry from '@sentry/react'Sentry.init()with any of the following configurations:Minimal Configuration (Fails)
With Empty Integrations (Fails)
With Default Integrations (Fails)
With Explicit Transport/StackParser (Fails)
Full Configuration (Fails)
Result: All configurations fail with the same error.
Expected Behavior
Sentry should initialize successfully with any valid configuration, allowing the application to continue loading.
Actual Behavior
Sentry initialization throws
TypeError: Cannot read properties of undefined (reading 'id')in theapplyDefaultOptionsfunction, preventing the application from loading.Debugging Evidence
Verified Working Conditions
dsnType: 'string', dsnLength: 95)windowExists: true)sentryExists: true, sentryInitExists: true)browserTracingIntegration,replayIntegration,makeFetchTransport,defaultStackParser, etc.)What We Tried
dsn- ❌ Failedintegrations: []array - ❌ FailedgetDefaultIntegrations()- ❌ FailedtransportandstackParser- ❌ FailedbrowserTracingIntegration) - ❌ FailedSentry.initto inspect options - All options correctly passed, error occurs in internal codeWorkaround
Downgrading to
@sentry/react@^8.55.0resolves the issue. The same configuration works correctly with v8.Code Example
Additional Context
@sentry/react@^8.55.0Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding
+1orme too, to help us triage it.