-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
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/nextjs
SDK Version
8.28.0
Framework Version
Next 14.2.3
Link to Sentry event
Reproduction Example/SDK Setup
next.config.js
const { withSentryConfig } = require('@sentry/nextjs');
module.exports = withSentryConfig(
module.exports,
{
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options
// Suppresses source map uploading logs during build
silent: false,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
},
{
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,
// Transpiles SDK to be compatible with IE11 (increases bundle size)
transpileClientSDK: true,
// Hides source maps from generated client bundles
hideSourceMaps: true,
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
productionBrowserSourceMaps: true,
},
);
sentry.client.config.ts
import * as Sentry from '@sentry/nextjs';
if (process.env.NEXT_PUBLIC_SENTRY_DSN != null) {
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
tracesSampleRate: 0.1,
debug: false,
replaysOnErrorSampleRate: 0.1,
replaysSessionSampleRate: 0.1,
integrations: [
Sentry.replayIntegration({
maskAllText: true,
blockAllMedia: true,
}),
],
});
}
src/instrumentation.ts
import { Attributes, Context, Link, SpanKind } from '@opentelemetry/api';
import { W3CTraceContextPropagator } from '@opentelemetry/core';
import {
Sampler,
SamplingDecision,
SamplingResult,
} from '@opentelemetry/sdk-trace-base';
import { SEMRESATTRS_DEPLOYMENT_ENVIRONMENT } from '@opentelemetry/semantic-conventions';
import * as Sentry from '@sentry/nextjs';
import { registerOTel } from '@vercel/otel';
import { getAppVariant, getFullConfig } from './config/util/getConfig';
export const TRACER_NAME = 'salsa';
export function register() {
const {
public: { sentry },
} = getFullConfig();
registerOTel({
serviceName: <redacted_service_name>
propagators: [new W3CTraceContextPropagator()],
traceSampler: excludeHealthChecks,
attributes: {
[SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]: getAppVariant(),
},
});
if (sentry.enabled) {
const nextRuntime = process.env.NEXT_RUNTIME;
if (nextRuntime === 'nodejs' || nextRuntime === 'edge') {
Sentry.init({
dsn: sentry.dsn,
tracesSampleRate: sentry.tracesSampleRate,
debug: sentry.debug,
});
}
}
}
const excludeHealthChecks: Sampler = {
shouldSample: function (
_context: Context,
_traceId: string,
spanName: string,
_spanKind: SpanKind,
_attributes: Attributes,
_links: Link[],
): SamplingResult {
if (/api\/health/.test(spanName)) {
return { decision: SamplingDecision.NOT_RECORD };
}
return { decision: SamplingDecision.RECORD_AND_SAMPLED };
},
};
Steps to Reproduce
We have some (not all) issues in Sentry with missing stack frames because there is no uploaded source file with the same debug id. What's interesting is that the debug ids do exist in the stack frame but it just looks like they can't be matched up with source files that should have been uploaded with next build
. Some potential clues I've noticed:
- All of the issues with unlinked stack traces seem to be originating from the client bundle - issues in server side code seems to be getting linked correctly
- Most of the errors (potentially all, but it's difficult to verify) with missing source files are originating in framework or dependency code. But my understanding is that even dependencies should be uploaded to Sentry if they end up in your production bundle (please correct me if I'm wrong about this).
Some more info on our setup:
- We are running next.js in a Docker container on ECS
- Source maps and source files are being uploaded in our CI/CD production build on CircleCI. I did turn on verbose logging here
silent: false
in the Sentry config to see if there were any issues. I did notice some warnings like- warning: could not determine a source map reference (Could not auto-detect referenced sourcemap for ~/<replace_with_uuid>.js)
but when I investigated into those files it seems like it was just for a file with a default export and no real JS code so I think it was a bit of a red herring. Also it was complaining about the missing source map NOT the source file which is different than the described problem in the UI. - I have verified that we do have some sourcemaps and source files uploaded to Sentry under Settings > Projects > Source Maps > Artifact Bundles but I'm a bit stumped on how to debug further why not ALL of the source files are getting uploaded. Or more generally how could there be a debug ID in the stack trace but missing a matching source file in Sentry?
Expected Result
I expect the stack frame to be correctly linked to source code like other issues in our project:
Actual Result
staaky, owenjeon, kouliavtsev, tomups and karolina-szlenk
Metadata
Metadata
Assignees
Labels
Projects
Status
Waiting for: Product Owner