getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
8.02k stars 1.59k forks source link

Next15 `dynamicIO` throws an error when sentry is enabled #14118

Open Zeko369 opened 4 weeks ago

Zeko369 commented 4 weeks ago

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.36.0-alpha.1

Framework Version

next@15.0.2-canary.10

Link to Sentry event

No response

Reproduction Example/SDK Setup

No response

Steps to Reproduce

  1. bunx create-next-app@canary
  2. npx @sentry/wizard@latest -i nextjs --saas --org YOUR_ORG --project YOUR_PROJECT
  3. Enable dynamicIO in next.config.ts
    const nextConfig: NextConfig = {
    /* config options here */
    experimental: {
    dynamicIO: true,
    },
    };
  4. npm run dev

Expected Result

No error thrown and page works

Actual Result

While the page does load, an error is thrown in the console

Error: Route "/" 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 io (file:///Users/franzekan/sandbox/next15-sentry/node_modules/next/src/server/node-environment-extensions/utils.tsx:33:31)
    at randomUUIDExpression (file:///Users/franzekan/sandbox/next15-sentry/node_modules/next/src/server/node-environment-extensions/web-crypto.tsx:40:7)
    at Object.uuid4 (webpack://next15-sentry/node_modules/@sentry/utils/build/cjs/misc.js?0b55:19:0)
    at Object.generatePropagationContext (webpack://next15-sentry/node_modules/@sentry/utils/build/cjs/propagationContext.js?1d5b:10:0)
    at new ScopeClass (webpack://next15-sentry/node_modules/@sentry/core/build/cjs/scope.js?c744:73:0)
    at ScopeClass.clone (webpack://next15-sentry/node_modules/@sentry/core/build/cjs/scope.js?c744:80:0)
    at SentryContextManager.with (webpack://next15-sentry/node_modules/@sentry/opentelemetry/build/cjs/index.js?fd8c:1383:0)
    at ContextAPI.with (file:///Users/franzekan/sandbox/next15-sentry/node_modules/@opentelemetry/api/src/api/context.ts:77:42)
    at spanContext (file:///Users/franzekan/sandbox/next15-sentry/node_modules/next/src/server/lib/trace/tracer.ts:303:24)
    at trace (file:///Users/franzekan/sandbox/next15-sentry/node_modules/next/dist/compiled/next-server/dist/src/server/app-render/create-component-tree.tsx:43:21)
    at createComponentTree (file:///Users/franzekan/sandbox/next15-sentry/node_modules/next/dist/compiled/next-server/dist/src/server/app-render/app-render.tsx:698:25)
    at run (file:///Users/franzekan/sandbox/next15-sentry/node_modules/next/dist/compiled/next-server/dist/src/server/app-render/app-render.tsx:2024:61)
  17 |   try {
  18 |     if (crypto && crypto.randomUUID) {
> 19 |       return crypto.randomUUID().replace(/-/g, '');
  20 |     }
  21 |     if (crypto && crypto.getRandomValues) {
  22 |       getRandomByte = () => {
lforst commented 4 weeks ago

Sup man! :) Thanks for raising. I have an eye on dynamicIO, but for now it is too early for us to support it. I will raise to Vercel that this has a veeery high chance of breaking a lot of apps actually.