Skip to content

Cannot deploy my NextJS app to SST with Sentry's config #20951

@jcohenho

Description

@jcohenho

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

10.53.1

Framework Version

16.1.6

Link to Sentry event

No response

Reproduction Example/SDK Setup

I am experiencing this in my NextJS + SST setup:

If I try to deploy with withSentryConfig(nextConfig, {...}) enabled in next.config.js, I get the following error:


┌──────────────────────────────┐
│ OpenNext — Generating bundle │
└──────────────────────────────┘

Bundling middleware function...
Bundling static assets...
Bundling cache assets...
Building server function: default...
file:///private/var/folders/cz/2jxz3hfs1w7czmcp87d0l50c0000fn/T/open-next-tmpbgBnDF/next.config.mjs:11
  throw Error('Dynamic require of "' + x + '" is not supported');
        ^

Error: Dynamic require of "fs" is not supported

Steps to Reproduce

  1. Add this to my next.config.ts:
import { withSentryConfig } from '@sentry/nextjs'
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  /* config options here */
}

export default withSentryConfig(nextConfig, {
  org: 'myorg',
  project: 'myproject',
  // Upload source maps for readable stack traces
  authToken: process.env.SENTRY_AUTH_TOKEN,
  // Route Sentry requests through your server (avoids ad-blockers)
  tunnelRoute: '/sentry-tunnel',
  silent: !process.env.CI,
})

  1. Deploy with SST via npx sst deploy

Expected Result

I expect the deploy to succeed

Actual Result

I am experiencing this in my NextJS + SST setup:

If I try to deploy with withSentryConfig(nextConfig, {...}) enabled in next.config.js, I get the following error:


┌──────────────────────────────┐
│ OpenNext — Generating bundle │
└──────────────────────────────┘

Bundling middleware function...
Bundling static assets...
Bundling cache assets...
Building server function: default...
file:///private/var/folders/cz/2jxz3hfs1w7czmcp87d0l50c0000fn/T/open-next-tmpbgBnDF/next.config.mjs:11
  throw Error('Dynamic require of "' + x + '" is not supported');
        ^

Error: Dynamic require of "fs" is not supported

Additional Context

No response

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions