Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uncaughtException: parentSpan.transaction.getDynamicSamplingContext is not a function after upgrading to latest version #7073

Closed
3 tasks done
jcasner opened this issue Feb 7, 2023 · 6 comments
Labels
Package: node Issues related to the Sentry Node SDK Type: Bug

Comments

@jcasner
Copy link

jcasner commented Feb 7, 2023

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/node

SDK Version

7.36.0

Framework Version

Node v16.15.1

Link to Sentry event

https://sentry.io/organizations/trayt/issues/3920849890/?query=is%3Aunresolved&referrer=issue-stream

SDK Setup

Sentry.init({
  dsn: config.sentry.dsn,
  environment: config.sentry.environment,
  enabled: config.isRunningOnServer,
  integrations: [
    // enable HTTP calls tracing
    new Sentry.Integrations.Http({ tracing: true }),
    // enable Express.js middleware tracing
    new Tracing.Integrations.Express({
      // to trace all requests to the default router
      app,
    }),
  ],
  release: VERSION,
  tracesSampleRate: config.sentry.tracesSampleRate,
})

Steps to Reproduce

  1. Upgrade from Sentry 7.11.1
  2. Start server
  3. See server crash

Expected Result

Server starts successfully

Actual Result

Server halts soon after starting. Interestingly, Sentry still captures the exception, so it is initializing.

uncaughtException: parentSpan.transaction.getDynamicSamplingContext is not a function
TypeError: parentSpan.transaction.getDynamicSamplingContext is not a function
    at Object.wrappedMethod [as request] (/opt/trayt/node_modules/@sentry/node/cjs/integrations/http.js:167:69)
    at makeRequest (/opt/trayt/node_modules/dd-trace/packages/dd-trace/src/exporters/common/request.js:127:24)
    at request (/opt/trayt/node_modules/dd-trace/packages/dd-trace/src/exporters/common/request.js:150:3)
@Lms24
Copy link
Member

Lms24 commented Feb 7, 2023

Hi @jcasner, thanks for reporting!

Usually, such an errors occur if you have misaligned @sentry/ package versions.

Please check if all your @sentry/ (node, core, utils, types, tracing, etc.) packages are updated to the same version.
It's best to check your yarn or NPM lock file for that, as likely more Sentry packages are installed in your node_modules folder than what's listed in your package.json

@Lms24 Lms24 added Status: Needs Information Package: node Issues related to the Sentry Node SDK and removed Status: Untriaged labels Feb 7, 2023
@jcasner
Copy link
Author

jcasner commented Feb 7, 2023

@Lms24 thanks for the quick response - we found this by merging the dependabot PR to upgrade the main package, so the 2 (@sentry/tracing and @sentry/node) were out of sync. We'll test this out and report back if we need to reopen this.

@edzis
Copy link

edzis commented Aug 23, 2023

Can you please support an edge use-case in context of micro-frontends where the current transaction might be created by a different version of sentry used by a child application.
It looks like you would only need to check if the getDynamicSamplingContext function exists on transaction before calling it.

For us this is is causing issues reporting events from one subsystem while a transaction form another subsystem is is active. The effects can be as small as button click not working to as sever as broken screens due to startup sequence being interrupted.

It looks like this started after we updated the main shell to sentry >= 7.13.0 which introduced this 347fbe4#diff-e1c283d759a823b7185017fd2b9f74415c415fac8865d9808c04826ddeda961fR232-R235

@Lms24
Copy link
Member

Lms24 commented Aug 24, 2023

Hi @edzis, we can do this but given that you already took a look at this, would you be interested in opening a PR with the check yourself? Happy to review!

Otherwise, I'll backlog this and try to get to it in the coming weeks.

@edzis
Copy link

edzis commented Feb 2, 2024

Looking at the code it seems this was fixed via #10094

@Lms24 @Angelodaniel can you please verify that the latest version now supports interacting with transactions from sub-applications using older versions of Sentry, like 7.12.0?

@Lms24
Copy link
Member

Lms24 commented Feb 2, 2024

Hey @edzis so if your only concern was that transaction.getDynamicSamplingContext was called without a definedness check, I can tell you that we don't call this function internally anymore since v7.93.0. As you probably saw in #10094, it was replaced by a global helper function getDynamicSamplingContextFromSpan. However, this function also needs to be present, meaning all your Sentry packages have to be on at least 7.93.0.

Given that using multiple versions of a Sentry SDK on the same site is not something we support, I cannot guarantee that there aren't other problems similar to the one you reported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: node Issues related to the Sentry Node SDK Type: Bug
Projects
None yet
Development

No branches or pull requests

3 participants