Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nextjs] v7.29.0 breaks reading next.config.js resulting into missing runtimeConfig #6691

Closed
3 tasks done
vire opened this issue Jan 9, 2023 · 5 comments
Closed
3 tasks done

Comments

@vire
Copy link

vire commented Jan 9, 2023

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/nextjs

SDK Version

7.29.0

Framework Version

@sentry/nextjs@7.29.0

Link to Sentry event

No response

Steps to Reproduce

  1. run yarn add -D @sentry/nextjs
  2. have a next.config.js exporting a function
const { withSentryConfig } = require('@sentry/nextjs')
// see https://nextjs.org/docs/api-reference/next.config.js/introduction
module.exports = (phase, { defaultConfig }) => {
  /**
   * @type {import('next').NextConfig}
   */
  const nextConfig = {
    /* config options here */
  }
  return withSentryConfig(defaultConfig)
}


1 .

see warns


warn  - Invalid next.config.js options detected: 
  - The root value must be an object but it was a function.

See more info here: https://nextjs.org/docs/messages/invalid-next-config
warn  - Detected next.config.js, no exported configuration found. https://nextjs.org/docs/messages/empty-configuration
info  - automatically enabled Fast Refresh for 1 custom loader
^C%              

Expected Result

the next.config.js file should be read as without errors

Actual Result

window.NEXT_DATA.runtimeConfig is missing

@lforst
Copy link
Member

lforst commented Jan 9, 2023

Please wrap the exported function with withSentryConfig:

const { withSentryConfig } = require('@sentry/nextjs')
// see https://nextjs.org/docs/api-reference/next.config.js/introduction
module.exports = withSentryConfig((phase, { defaultConfig }) => {
  /**
   * @type {import('next').NextConfig}
   */
  return nextConfig = {
    /* config options here */
  }
})

@vire
Copy link
Author

vire commented Jan 9, 2023

@lforst I've tried that out, but @sentry/nextjs@7.17.3 works with my current setup, upgrading to @sentry/nextjs@7.29 broke my production env

@lforst
Copy link
Member

lforst commented Jan 9, 2023

@vire If you look at the method signature of withSentryConfig it always either returned an object or a function. You need to consider that. If your setup breaks with the new version, it always was faulty.

@vire
Copy link
Author

vire commented Jan 9, 2023

@lforst Ok what you suggest works,

but with @sentry/nextjs@7.29.0 I'm hitting another issue with the @sentry/replay lib package it contains hardcoded path to ./node_modules which does not work with yarn berry

image

[webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Resolving 'rrweb/es/rrweb/packages/rrweb/src/entries/all' in /Users/path/to/project/.yarn/virtual/@sentry-replay-virtual-b637ba30d9/0/cache/@sentry-replay-npm-7.29.0-e553e78caf-539e18c128.zip/node_modules/@sentry/replay/cjs for build dependencies doesn't lead to expected result '/Users/path/to/project/.yarn/virtual/@sentry-replay-virtual-b637ba30d9/0/cache/@sentry-replay-npm-7.29.0-e553e78caf-539e18c128.zip/node_modules/@sentry/replay/cjs/node_modules/rrweb/es/rrweb/packages/rrweb/src/entries/all.js', but to 'Error: Can't resolve 'rrweb/es/rrweb/packages/rrweb/src/entries/all' in '/Users/path/to/project/.yarn/virtual/@sentry-replay-virtual-b637ba30d9/0/cache/@sentry-replay-npm-7.29.0-e553e78caf-539e18c128.zip/node_modules/@sentry/replay/cjs'' instead. Resolving dependencies are ignored for this path.

@lforst
Copy link
Member

lforst commented Jan 9, 2023

@vire Great!

As for the other issue, we're tracking that here: #6690

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants