sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Error: Route "" used `searchParams.__sentry_skip_normalization__`. `searchParams` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis

Open m-nathani opened this issue 7 months ago • 6 comments

Route Navigation Errors with sendDefaultPii Configuration

Is there an existing issue for this?

  • [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • [x] I have reviewed the documentation https://docs.sentry.io/
  • [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

9.28.0

Framework Version

React 19 and Next 15.3.3

Link to Sentry event

No response

Reproduction Example/SDK Setup

Environment

  • Package: @sentry/nextjs ( 9.28.0)
  • Framework: Next.js 15
  • Configuration Files: sentry.edge.config.ts and/or sentry.server.config.ts

Issue Description

After updating to the latest version of @sentry/nextjs and adding the sendDefaultPii: true configuration option, navigation between routes triggers invalid parameter-related errors that prevent proper route transitions.

sentry.edge.config.ts

// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).
// The config you add here will be used whenever one of the edge features is loaded.
// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import { env } from '@/env';
import * as Sentry from '@sentry/nextjs';

Sentry.init({
  dsn: env.NEXT_PUBLIC_SENTRY_DSN,
  environment: env.NEXT_PUBLIC_APP_ENV,

  // Adds request headers and IP for users, for more info visit:
  // https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#sendDefaultPii
  sendDefaultPii: true,

  // Define how likely traces are sampled.
  tracesSampleRate: env.NEXT_PUBLIC_APP_ENV === 'production' ? 0.1 : 0.6,

  // Setting this option to true will print useful information to the console while you're setting up Sentry.
  debug: false,
});

sentry.server.config.ts

// This file configures the initialization of Sentry on the server.
// The config you add here will be used whenever the server handles a request.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import { env } from '@/env';
import * as Sentry from '@sentry/nextjs';

Sentry.init({
  dsn: env.NEXT_PUBLIC_SENTRY_DSN,
  environment: env.NEXT_PUBLIC_APP_ENV,

    // Adds request headers and IP for users, for more info visit:
  // https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#sendDefaultPii
  sendDefaultPii: true,

  // Define how likely traces are sampled.
  tracesSampleRate: env.NEXT_PUBLIC_APP_ENV === 'production' ? 0.1 : 0.6,

  // Setting this option to true will print useful information to the console while you're setting up Sentry.
  debug: false,
});

Steps to Reproduce

Steps to Reproduce

  1. Update @sentry/nextjs to the latest version
  2. Add the following configuration to sentry.edge.config.ts or sentry.server.config.ts:
    // Adds request headers and IP for users, for more info visit:
    // https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#sendDefaultPii
    sendDefaultPii: true,
    
  3. Navigate between routes in the Next.js application
  4. Observe route navigation errors related to invalid parameters

Workaround

The issue is resolved by either:

  • Downgrading @sentry/nextjs to a previous version, OR
  • Removing the sendDefaultPii: true configuration

Additional Context

  • The errors specifically mention issues with route parameters
  • The parameter errors appear to be false positives as they disappear when the Sentry configuration is modified
  • This suggests the sendDefaultPii option may be interfering with Next.js's internal route parameter handling or validation

Expected Result

Expected Behavior

Route navigation should work normally without throwing parameter-related errors when sendDefaultPii is enabled.

Impact

This prevents users from enabling PII collection for better debugging context while maintaining stable route navigation in their Next.js applications.

Actual Result

Actual Behavior

Navigation between routes fails with parameter validation errors that appear to be invalid/spurious.

> next dev -p 3012

   ▲ Next.js 15.3.3
   - Local:        http://localhost:3012
   - Network:      http://192.168.0.160:3012
   - Environments: .env
   - Experiments (use with caution):
     · clientTraceMetadata

 ✓ Starting...
 ○ Compiling /instrumentation ...
 ✓ Compiled /instrumentation in 9.5s (938 modules)
 ✓ Ready in 16.2s
 ○ Compiling /middleware ...
 ✓ Compiled /middleware in 1673ms (624 modules)
 ○ Compiling /[locale]/partner/[slug] ...
 ✓ Compiled /[locale]/partner/[slug] in 13s (3514 modules)
 GET /en/partner/kwc-singapore 200 in 18157ms
Error: Route "/[locale]/partner/[slug]" used `...params` or similar expression. `params` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
Error: Route "/[locale]/partner/[slug]" used `params.locale`. `params` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
Error: Route "/[locale]/partner/[slug]" used `params.slug`. `params` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
Error: Route "/[locale]/partner/[slug]" used `searchParams.__isVue`. `searchParams` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
Error: Route "/[locale]/partner/[slug]" used `searchParams._isVue`. `searchParams` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
Error: Route "/[locale]/partner/[slug]" used `searchParams.__sentry_skip_normalization__`. `searchParams` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
Error: Route "/[locale]/partner/[slug]" used `searchParams.__sentry_override_normalization_depth__`. `searchParams` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
Error: Route "/[locale]/partner/[slug]" used `Object.keys(searchParams)` or similar. `searchParams` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)

m-nathani avatar Jun 11 '25 08:06 m-nathani

Hey @m-nathani thanks for reporting this!

I've found one location in our code where this error could be coming from:

https://github.com/getsentry/sentry-javascript/blob/f56cc3ec87fb47c79c1e4e572b9956d0815a2b48/packages/nextjs/src/common/wrapGenerationFunctionWithSentry.ts#L56-L62

Downgrading @sentry/nextjs to a previous version,

Can you tell me which version still works for you? This will help us to narrow it down further.

Also just to confirm: Do you only get these errors in your server console logs or also client-side in the browser console?

Lms24 avatar Jun 11 '25 08:06 Lms24

Downgrading @sentry/nextjs to a previous version,

Currently i was on 9.23.0 and upgraded to 9.28.0, however not exactly sure between 9.23.0 to 9.28.0 which one has issue in it

Also just to confirm: Do you only get these errors in your server console logs or also client-side in the browser console?

Server side logs

what should be workaround for this by the time? would be better to remove sendDefaultPii or downgrade ?

m-nathani avatar Jun 11 '25 08:06 m-nathani

Thanks for getting back to me! I'll try to reproduce and narrow it down further with the version margin.

If you don't need a specific feature from the newer versions, I'd recommend downgrading, since you might miss data that's gated with sendDefaultPii.

Lms24 avatar Jun 11 '25 09:06 Lms24

@Lms24 Noted, your welcome !

m-nathani avatar Jun 11 '25 09:06 m-nathani

@m-nathani I tried reproducing this today but couldn't reproduce it. Now, I'm definitely not a Next expert, so if you could take a look at https://github.com/Lms24/gh-sentry-javascript-16542-nextjs-sendDefaultPii-param and let me know what I need to change to repro it, I'd appreciate it a lot!

Lms24 avatar Jun 13 '25 11:06 Lms24

@Lms24 Alright, let me try it.

m-nathani avatar Jun 16 '25 02:06 m-nathani

@Lms24 just an update: i am trying to reproduce, however no luck yet..

I did the followings uptil now:

commit c97e401aa4a95f012f182aaca30f77c5e3d98648 (HEAD -> reproduce-sendDefaultPii-param)
Author: Murtaza <[email protected]>
Date:   Mon Jun 16 12:09:22 2025 +0800

    WIP: trying to reproduce with the structure of the app where from where the error came
    1. adding next-intl
    2. moving app/ to src/
    3. enabling static rendering
    4. moving package version for react and sentry reproducible main app
    5. adding a middleware
    6. update layouts and pages to work next-intl to make it reproducible

Will keep digging... 🤞🏼

m-nathani avatar Jun 17 '25 03:06 m-nathani

Replicated in our project when run locally.

I found the error would only show on page refresh. When navigating to other pages, the error was not thrown.

Clearing out .next might help reproduce the issue.

philatcd avatar Jun 17 '25 23:06 philatcd

Hello @m-nathani Could you provide a reproduction on that so we can look into it in detail? I tried to reproduce this but no luck

RulaKhaled avatar Jun 18 '25 10:06 RulaKhaled

I have made a repository to reproduce this issue: https://github.com/daanvosdewael/next-sentry-async-params. It has the issue documented in the README.md, but the TL;DR is this:

  • add sendDefaultPii: true to the Sentry "server" config
  • start the Next.js development server
  • open in the browser the homepage
  • see the Next.js error output in the console (both terminal and dev tools)

daanvosdewael avatar Jun 28 '25 14:06 daanvosdewael

@daanvosdewael thanks for creating the repro, we'll look into it!

chargome avatar Jun 30 '25 11:06 chargome

Having the same issue, version 9.33.0.

Removing sendDefaultPii: true from both edge and server config, 'fixed' the issue temporarily.

Error log for my case:

Error: Route "/" used `...params` or similar expression. `params` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
    at Function.entries (<anonymous>)
    at Object.apply (webpack-internal:/(rsc)/app/sentry-wrapper-module:47:9)
  45 |         baggageHeader,
  46 |         headers,
> 47 |       }).apply(thisArg, args);
     |         ^
  48 |     },
  49 |   });
  50 | } else {

DanishNasarudin avatar Jul 01 '25 04:07 DanishNasarudin

Hi, we're working on a fix. Thanks for reporting in.

andreiborza avatar Jul 01 '25 07:07 andreiborza

A PR closing this issue has just been released 🚀

This issue was referenced by PR #17162, which was included in the 10.0.0 release.

github-actions[bot] avatar Jul 31 '25 15:07 github-actions[bot]