Skip to content

span.spanContext is not a function #10348

Description

@arthurfiorette

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/node

SDK Version

7.98.0

Framework Version

@immobiliarelabs/fastify-sentry: 8.0.0 and @prisma/client: 5.8.1

Link to Sentry event

Self hosted instance

SDK Setup

Sentry.init({
  dsn: Env.SENTRY_DSN,
  environment: Env.FDM_ENV,
  release: Env.FDM_VERSION,
  sampleRate: 1,
  enableTracing: true,
  autoSessionTracking: true,
  includeLocalVariables: true,
  integrations: [
    new Integrations.Prisma({ client: PRISMA }),
    new Integrations.LocalVariables({ captureAllExceptions: true })
  ],
  shouldHandleError: (err, _, reply) => !!err || reply.statusCode >= 500,
  extractUserData: (request) => ({
    username: request.user ? request.user.name : 'anonymous',
    id: request.id
  }),
  errorResponse: (error, _, reply) => reply.send(error)
})

Steps to Reproduce

We've been using it with https://github.com/immobiliare/fastify-sentry, but the error seems to be from this package.

I'm not sure if I could show the actual code here as it is from my job and I signed a NDA, but would love some guidance to help you guys debugging this with me, if possible.

Expected Result

Sending traces to sentry should work normally.

Actual Result

TypeError: span.spanContext is not a function
    at Object.spanToTraceContext (<redacted>/node_modules/.pnpm/@sentry+core@7.98.0/node_modules/@sentry/src/utils/spanUtils.ts:13:55)
    at applySpanToEvent (<redacted>/node_modules/.pnpm/@sentry+core@7.98.0/node_modules/@sentry/src/utils/applyScopeDataToEvent.ts:179:29)
    at Object.applyScopeDataToEvent (<redacted>/node_modules/.pnpm/@sentry+core@7.98.0/node_modules/@sentry/src/utils/applyScopeDataToEvent.ts:20:5)
    at Object.prepareEvent (<redacted>/node_modules/.pnpm/@sentry+core@7.98.0/node_modules/@sentry/src/utils/prepareEvent.ts:100:3)
    at NodeClient._prepareEvent (<redacted>/node_modules/.pnpm/@sentry+core@7.98.0/node_modules/@sentry/src/baseclient.ts:636:20)
    at NodeClient._prepareEvent (<redacted>/node_modules/.pnpm/@sentry+core@7.98.0/node_modules/@sentry/src/server-runtime-client.ts:252:18)
    at NodeClient._processEvent (<redacted>/node_modules/.pnpm/@sentry+core@7.98.0/node_modules/@sentry/src/baseclient.ts:732:20)
    at NodeClient._captureEvent (<redacted>/node_modules/.pnpm/@sentry+core@7.98.0/node_modules/@sentry/src/baseclient.ts:675:20)
    at NodeClient.captureEvent (<redacted>/node_modules/.pnpm/@sentry+core@7.98.0/node_modules/@sentry/src/baseclient.ts:225:12)
    at NodeClient.captureEvent (<redacted>/node_modules/.pnpm/@sentry+core@7.98.0/node_modules/@sentry/src/server-runtime-client.ts:127:18)
    at Scope.captureEvent (<redacted>/node_modules/.pnpm/@sentry+core@7.98.0/node_modules/@sentry/src/scope.ts:683:18)
    at Hub.captureEvent (<redacted>/node_modules/.pnpm/@sentry+core@7.98.0/node_modules/@sentry/src/hub.ts:353:21)
    at Transaction.finish (<redacted>/node_modules/.pnpm/@sentry+core@7.74.1/node_modules/@sentry/src/tracing/transaction.ts:141:1)
    at Object.<anonymous> (<redacted>/node_modules/.pnpm/@immobiliarelabs+fastify-sentry@8.0.0/node_modules/@immobiliarelabs/fastify-sentry/lib/request.js:120:31)
    at onResponseHookIterator (<redacted>/node_modules/.pnpm/fastify@4.25.2/node_modules/fastify/lib/hooks.js:270:10)
    at next (<redacted>/node_modules/.pnpm/fastify@4.25.2/node_modules/fastify/lib/hooks.js:243:18)
    at hookRunner (<redacted>/node_modules/.pnpm/fastify@4.25.2/node_modules/fastify/lib/hooks.js:265:5)
    at ServerResponse.onResFinished (<redacted>/node_modules/.pnpm/fastify@4.25.2/node_modules/fastify/lib/reply.js:796:7)
    at ServerResponse.emit (node:events:530:35)
    at ServerResponse.emit (node:domain:488:12)
    at onFinish (node:_http_outgoing:1005:10)
    at callback (node:internal/streams/writable:756:21)
    at afterWrite (node:internal/streams/writable:701:5)
    at afterWriteTick (node:internal/streams/writable:687:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)

Activity

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

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions