Skip to content

Error serializing ._sentryBaggage returned from getServerSideProps #12102

Closed
@dorin-flooz

Description

@dorin-flooz

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

8.2.1

Framework Version

NextJs 14.2.3

Link to Sentry event

No response

SDK Setup

import * as Sentry from '@sentry/nextjs';
import { appVersionUtils } from './src/modules/application/utils/app-version-utils';

const SENTRY_DSN = process.env.SENTRY_DSN ?? process.env.NEXT_PUBLIC_SENTRY_DSN;
const APP_VERSION = appVersionUtils.getAppVersion();

const commonSentryOptions = {
    release: APP_VERSION,
    environment: process.env.NEXT_PUBLIC_ENV,
    dsn: SENTRY_DSN,
    enabled: false, // process.env.NODE_ENV !== 'development',
    tracesSampleRate: 1,
};

export async function register() {
    if (process.env.NEXT_RUNTIME === 'nodejs') {
        Sentry.init({
            ...commonSentryOptions,
        });
    }

    if (process.env.NEXT_RUNTIME === 'edge') {
        Sentry.init({
            ...commonSentryOptions,
        });
    }
}

Steps to Reproduce

After upgrading to "@sentry/nextjs": "8.2.1", we get the following error:

Error: Error serializing `._sentryBaggage` returned from `getServerSideProps` in "/profile/[ensOrAddress]".
Reason: `undefined` cannot be serialized as JSON. Please use `null` or omit this value.

When reverting to "@sentry/nextjs": "7.115.0" the error goes away. How can we debug and fix this? Searched for sentryBaggage already, but nothing came up.

Also - how come we get Sentry errors in our local dev env, when Sentry is explicitly disabled through enabled: false in our Sentr.init?

Expected Result

  • Sentry should not be enabled in local env
  • Sentry should not prevent NextJs pages from loading in case getServerSideProps fails

Actual Result

  • Sentry is enabled in local env
  • Sentry prevents NextJs pages from loading in case getServerSideProps fails

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions