-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Closed
Copy link
Labels
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/browser
SDK Version
8.36
Framework Version
Next 15 canary
Link to Sentry event
Reproduction Example/SDK Setup
// instrumentation.ts
import * as Sentry from "@sentry/nextjs"
export const onRequestError = Sentry.captureRequestError
export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
await import("./sentry.server.config")
}
if (process.env.NEXT_RUNTIME === "edge") {
await import("./sentry.edge.config")
}
}
// sentry.server.config
import { nodeProfilingIntegration } from "@sentry/profiling-node"
import { initSentry } from "./sentry.config"
initSentry({
integrations: [nodeProfilingIntegration()],
})
// sentry.config
import { addBreadcrumb, captureMessage, init } from "@sentry/nextjs"
import type { BrowserOptions, ErrorEvent, EventHint } from "@sentry/nextjs"
import {
DENY_URLS,
IGNORE_ERRORS,
matchesFilenameIgnorelist,
tracesSampler,
} from "./SENTRY_CONSTANTS"
export const SENTRY_DSN =
process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN
export const isProd =
process.env.NEXT_PUBLIC_VERCEL_ENV === "production" ||
process.env.SENTRY_DEBUGGING === "true"
export function initSentry(options: Partial<BrowserOptions> = {}): void {
if (!isProd) return
init({
release: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA,
denyUrls: DENY_URLS,
dsn:
SENTRY_DSN,
tracesSampler: (samplingContext) => tracesSampler(samplingContext, 0.25),
profilesSampleRate: 1.0,
debug: process.env.SENTRY_DEBUGGING === "true",
ignoreErrors: IGNORE_ERRORS,
beforeSend: beforeSendHandler,
enabled: isProd,
...options,
})
}
function beforeSendHandler(
event: ErrorEvent,
hint: EventHint
): ErrorEvent | null {
try {
const originalException = hint.originalException?.toString()
if (shouldIgnoreString(originalException)) {
return null
}
const syntheticException = hint.syntheticException?.toString()
if (shouldIgnoreString(syntheticException)) {
return null
}
const frames = event.exception?.values?.[0]?.stacktrace?.frames || []
if (
frames.some(
(frame) =>
shouldIgnoreString(frame.filename) ||
shouldIgnoreString(frame.module) ||
shouldIgnoreString(frame.function)
)
) {
return null
}
if (shouldIgnoreString(event?.exception?.values?.[0]?.value)) {
return null
}
} catch (e) {
console.error("Error filtering Sentry event", e)
addBreadcrumb({
message: "Error filtering Sentry event",
data: { error: e, event },
})
captureMessage("Error filtering Sentry event")
}
return event
}
function shouldIgnoreString(str: string | undefined): boolean {
if (!str) return false
// Check if the string matches any pattern in IGNORE_ERRORS
const matchesIgnoreErrors = IGNORE_ERRORS.some((ignore) => {
if (typeof ignore === "string") {
return str.toLowerCase().includes(ignore.toLowerCase())
} else if (ignore instanceof RegExp) {
return ignore.test(str)
}
return false
})
// Check if the string matches the filename ignore list
const matchesFilenameIgnore = matchesFilenameIgnorelist(str)
return matchesIgnoreErrors || matchesFilenameIgnore
}
Steps to Reproduce
I'm running Next 15 canary and the latest Sentry NextJS SDK (8.36).
I have the onRequestError configured in instrumentation.ts as per these docs, and I'm also properly importing the corresponding server/edge configs via instrumentation as per these docs.
Despite doing that, I'm still getting the stacktrace & error messages omitted in React server component errors.
Expected Result
The full stacktrace should be included.
Actual Result
The stacktrace and error message is omitted: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details
Metadata
Metadata
Assignees
Labels
Projects
Status
Waiting for: Product Owner