Skip to content

Sentry keeps saying that the SDK must be updated #6201

Closed

Description

@gabrielsch

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/nextjs

SDK Version

7.19

Framework Version

Nextjs 12

Link to Sentry event

https://sentry.io/organizations/newfront-pj/issues/3739878133/?project=6180684&query=is%3Aunresolved&referrer=issue-stream

Steps to Reproduce

We never used Sentry SDK on version 5.12 but for some reason Sentry still reports it under the wrong version.

Could this be related to the app being deployed in Vercel? Is it some kind of npm package caching issue?

Expected Result

Error to be reported on the expected SDK version.

Actual Result

Error being reported on an older/unknown version.
Screen Shot 2022-11-14 at 6 49 38 PM

Activity

  1. Lms24 commented on Nov 15, 2022

    @Lms24
    Member

    Hi @gabrielsch thanks for writing in! This seems a little strange but let's try to find what might be causing this!

    First, let's do a sanity check: You said that you can't recall ever having used the 5.12.1 version. Would you nevertheless mind checking your package-lock.json/yarn.lock or deleting and re-installing your node_modules? I'm not sure if there's some sort of version mismatch but weird behaviour like this happens quite often because of some weird dependency issues.

    One thing I find interesting is that when looking at your event, I find an error message on the top:

    Screenshot 2022-11-15 at 08 56 38

    We don't store SDK info in this variable but it might be worth investigating this a little more. Hence a few questions: Are you making modifications to the events (e.g. in beforeSend, beforeSendTransaction or custom event processors)? Do you set special init options (e.g. custom integrations, or perhaps you're setting _metadata?).
    Are you perhaps initializing Sentry manually (i.e. create a hub and client yourself instead via Sentry.init)?

  2. gabrielsch commented on Nov 15, 2022

    @gabrielsch
    Author

    @Lms24 just checked the lockfile and we are definitely installing the latest one (7.19)

    We do customize the event fingerprint and tags eventually, let me share the code with you:

    export function initializeSentryClient(config: SentryClientOptions): void {
      Sentry.init({
        dsn: config.dsn,
        tracesSampleRate: 0.25,
        environment: config.environment,
        debug: config.debug ?? IS_DEVELOPMENT,
        enabled: config.enabled ?? !IS_DEVELOPMENT,
        integrations: [new Replay()],
        ignoreErrors: [
          /Network error/,
          /ResizeObserver loop limit exceeded/,
          /network error \(Error\)/,
          /ResizeObserver loop completed with undelivered notifications/,
          /Illegal invocation/,
        ],
        // we should mutate the error on `beforeSend` because not all errors in the client side are
        // captured throug `captureClientException` (in case of uncaught exceptions)
        // using beforeSend is more reliable since it's the global handle
        beforeSend: (event, hint) => {
          const maybeFetcherError = get(hint.originalException, 'originalError.responseBody.error.json.fetcherError');
    
          if (isFetcherErrorLike(maybeFetcherError)) {
            const ddTraceId = maybeFetcherError.fetcherResponse.headers[TRACE_ID_HEADER];
            const responseJson = get(hint.originalException, 'originalError.responseBody.error.json');
    
            event.fingerprint = [responseJson.path, responseJson.type].filter(Boolean);
    
            event.tags = {
              ...event.tags,
              'dd.trace_id': ddTraceId,
              'dd.search': getDatadogSearchUrl(ddTraceId),
            };
          }
    
          return event;
        },
      });
    }

    We have a package wrapping some sentry config defaults, which uses @sentry/nextjs under the hoods.

    The next.js app itself uses this wrapper package to initialize sentry on sentry.client.config.ts and sentry.server.config.ts

  3. Lms24 commented on Nov 16, 2022

    @Lms24
    Member

    Interesting. On first glance I can't find anything that would mutate the SDK's metadata object. For a little more context, our SDK holds its info in the client options (which are based on the options passed to Sentry.init).
    The warning in the event suggests to me that something in the SDK's event processing pipeline might not work as intended.

    Let's check which version the SDK sets locally to its events. I'd suggest using this code:

    const sdkMetadata = Sentry.getCurrentHub().getClient().getOptions()._metadata;
    console.log(sdkMetadata);

    Insert it once after the Sentry.init call and in beforeSend. It'd be interesting to find out if the SDK has the wrong data from the beginning onwards or if there's anything happening to the client options which causes this.

  4. lobsterkatie commented on Nov 17, 2022

    @lobsterkatie
    Member

    A few thoughts here:

    • Is it possible there's a link to our CDN version of the browser SDK somewhere in your header? Something is making it think that not only is it version 5, it's the browser SDK, not the nextjs SDK. (The nextjs SDK didn't even exist until some time early in the 6.x era.)
    • It's also strange that sdkProcessingMetadata is making its way to Sentry, as we make a point to delete it before events go out the door. I suspect the version mismatch is to blame here, too, though. If a newer version of one package is adding it, but the code which is doing the sending is from an older version, then it wouldn't get deleted.

    Side note: This is a place where this would come in really handy.

  5. gabrielsch commented on Nov 17, 2022

    @gabrielsch
    Author

    @lobsterkatie @Lms24

    Hi folks, after spending some more time into this, I realized that the sentry.client wasn't enabled in our app due to a missing env var / config.

    After fixing it, issues started being reported in the expected version, however something weird was going on since we were receiving issues from the wrong version even with the client being disabled.

    Thank you and sorry for making you spending time on this 😄

  6. Lms24 commented on Nov 17, 2022

    @Lms24
    Member

    Great to hear that this is resolved 😄
    I'm gonna close this issue but feel free to tag us in case more needs to be done here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions