Skip to content

Next.js 15.4.2-canary+ error with crypto package #17058

@gianpaj

Description

@gianpaj

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

9.39.0

Framework Version

Next 15.4.2-canary.5

Link to Sentry event

No response

Reproduction Example/SDK Setup

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 * as Sentry from '@sentry/nextjs';

Sentry.init({
  dsn: 'https://...',

  // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
  tracesSampleRate: 1,
  integrations: [
    // Add the Vercel AI SDK integration
    Sentry.vercelAIIntegration({
      recordInputs: true,
      recordOutputs: true,
    }),
  ],

  // Setting this option to true will print useful information to the console while you're setting up Sentry.
  debug: false,
  enabled: process.env.NODE_ENV === 'production',
  _experiments: {
    enableLogs: true,
  },
});

Steps to Reproduce

npm run dev

Expected Result

no error :)

Actual Result

 GET /en/ 200 in 4986ms
[browser]  Server   Error: Route "/[lang]" used `crypto.randomUUID()` outside of `"use cache"` and without explicitly calling `await connection()` beforehand. See more info here: https://nextjs.org/docs/messages/next-prerender-crypto
    at Module.uuid4 (node_modules/.pnpm/@[email protected]/node_modules/@sentry/core/src/utils/misc.ts:34:21)
    at Module.generateTraceId (node_modules/.pnpm/@[email protected]/node_modules/@sentry/core/src/utils/propagationContext.ts:7:10)
    at new Scope (node_modules/.pnpm/@[email protected]/node_modules/@sentry/core/src/scope.ts:162:16)
    at Scope.clone (node_modules/.pnpm/@[email protected]/node_modules/@sentry/core/src/scope.ts:171:22)
    at LogSafely (unknown)
  32 |   try {
  33 |     if (crypto?.randomUUID) {
> 34 |       return crypto.randomUUID().replace(/-/g, '');
     |                     ^
  35 |     }
  36 |     if (crypto?.getRandomValues) {
  37 |       getRandomByte = () => { (unknown)

See this doc https://nextjs.org/docs/messages/next-prerender-crypto

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions