Skip to content

NextJS and lazy-loading replay warning top level await #12364

@sergio-milu

Description

@sergio-milu

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

8.3.0

Framework Version

NextJS 14.2.3

Link to Sentry event

No response

SDK Setup

/* sentry.client.config.js */
// This file configures the initialization of Sentry on the client.
// The config you add here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import { init, addIntegration } from '@sentry/nextjs';

init({
dsn: process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN ?? undefined,
environment: process.env.NEXT_PUBLIC_ENVIRONMENT ?? undefined,
tracesSampleRate: 1,
debug: false,
replaysOnErrorSampleRate: 1.0,
replaysSessionSampleRate: 0.1,

initialScope: {
tags: {
version: process.env.NEXT_PUBLIC_PACKAGE_VERSION ?? undefined,
},
},
ignoreTransactions: ['/ping'],
tracePropagationTargets: ['localhost', /^/(?!/)/],
integrations: [],
});

const { replayIntegration } = await import('@sentry/nextjs');
addIntegration(replayIntegration());

Steps to Reproduce

Having the sentry.client.config.js as stated in this issue, start nextjs dev server and you'll see warning in console (both terminal and browser)

Expected Result

No warnings in console

Actual Result

 ⚠ ./sentry.client.config.js
The generated code contains 'async/await' because this module is using "topLevelAwait".
However, your target environment does not appear to support 'async/await'.
As a result, the code may not run as expected or may cause runtime errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions