Skip to content

middleware.ts is causing this error: "Tracing extension 'startTransaction' is missing."  #9461

@Jezfx

Description

@Jezfx

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

7.77.0

Framework Version

18.2.0

Link to Sentry event

No response

SDK Setup

We use the default Sentry.init set up for the client, server and edge.

// sentry.client.config.ts, sentry.edge.config.ts, sentry.server.config.ts
import * as Sentry from '@sentry/nextjs'

Sentry.init({
  dsn: '__DSN__',
  tracesSampleRate: 1
})

Steps to Reproduce

This is a working CodeSandbox matching our techstack and set up.
https://codesandbox.io/p/github/Jezfx/sentry-next-middleware-issue/main

To recreate

Create this middleware file

// apps/demo/middleware.ts

import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'

export function middleware(request: NextRequest) {
  const url = request.nextUrl.clone()
  const res = NextResponse.rewrite(url)

  return res
}

This codesandbox has the above changes.

Error

This is what we're seeing in the terminal

Screenshot 2023-11-06 at 18 37 33

Expected Result

For us to use middleware as before upgrading@sentry/nextjs to 7.77.0.

Actual Result

This happened after we upgraded @sentry/nextjs to 7.77.0.
Since upgrading we get this error in the in terminal and also no production site data in our sentry.io dashboard anymore 🙁

Error:

Tracing extension 'startTransaction' is missing. You should 'init' the SDK before calling 'startTransaction'

This is causing issues in our live production site, any help is hugely appreciated 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions