Title: Cannot destructure property 'RawSource' of 'require(...)' as it is undefined error only when withSentryConfig is used and a site is viewed in Next dev mode · Issue #8541 · getsentry/sentry-javascript · GitHub
Open Graph Title: Cannot destructure property 'RawSource' of 'require(...)' as it is undefined error only when withSentryConfig is used and a site is viewed in Next dev mode · Issue #8541 · getsentry/sentry-javascript
X Title: Cannot destructure property 'RawSource' of 'require(...)' as it is undefined error only when withSentryConfig is used and a site is viewed in Next dev mode · Issue #8541 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/8541
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot destructure property 'RawSource' of 'require(...)' as it is undefined error only when withSentryConfig is used and a site is viewed in Next dev mode","articleBody":"### Is there an existing issue for this?\r\n\r\n- [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\r\n- [X] I have reviewed the documentation https://docs.sentry.io/\r\n- [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\r\n\r\n### How do you use Sentry?\r\n\r\nSentry Saas (sentry.io)\r\n\r\n### Which SDK are you using?\r\n\r\n@sentry/nextjs\r\n\r\n### SDK Version\r\n\r\n7.58.1\r\n\r\n### Framework Version\r\n\r\n13.4.10\r\n\r\n### Link to Sentry event\r\n\r\n_No response_\r\n\r\n### SDK Setup\r\n\r\n`next.config.js`:\r\n\r\n```javascript\r\nconst cspHeaders = require('./src/utils/csp.js');\r\n\r\nconst { env: clientEnv } = require('./src/utils/public/configuration.js');\r\n\r\nconst { withSentryConfig } = require('@sentry/nextjs');\r\nconst nextBuildId = require('next-build-id');\r\n\r\nconst bundleAnalyzer = require('@next/bundle-analyzer')({\r\n // eslint-disable-next-line n/no-process-env\r\n enabled: !!process.env.BUNDLE_ANALYSE\r\n});\r\n\r\n//This import allows for build time checking of the public environment variables\r\nclientEnv;\r\n\r\nconst securityHeaders = [\r\n {\r\n key: 'X-DNS-Prefetch-Control',\r\n value: 'on'\r\n },\r\n {\r\n key: 'Strict-Transport-Security',\r\n value: 'max-age=63072000; includeSubDomains; preload'\r\n },\r\n {\r\n key: 'X-XSS-Protection',\r\n value: '1; mode=block'\r\n },\r\n {\r\n key: 'X-Frame-Options',\r\n value: 'SAMEORIGIN'\r\n },\r\n {\r\n key: 'X-Content-Type-Options',\r\n value: 'nosniff'\r\n },\r\n {\r\n key: 'Referrer-Policy',\r\n value: 'no-referrer-when-downgrade'\r\n }\r\n];\r\n\r\nconst allPathsHeaders = [\r\n {\r\n key: 'X-Robots-Tag',\r\n value: 'noindex'\r\n },\r\n {\r\n key: 'Content-Security-Policy',\r\n value: cspHeaders\r\n }\r\n];\r\n\r\n/** @type {import('next').NextConfig} */\r\nconst nextConfig = {\r\n // We want prod sourcemaps for Rollbar/Sentry etc.\r\n productionBrowserSourceMaps: true,\r\n // Imperva's CDN will give us Brotli or Gzip compression, so this can take the load off the Next server:\r\n // @TODO: set this back to false when https://github.com/vercel/next.js/issues/48713 resolved\r\n compress: true,\r\n experimental: {\r\n // Disabled for now as experimental and https://github.com/vercel/next.js/issues/51286\r\n serverActions: false\r\n },\r\n images: {\r\n // Set a minimum cache TTL for images as the Azure blob storage product\r\n // image responses do not include a cache-control header\r\n minimumCacheTTL: 86400,\r\n remotePatterns: [\r\n {\r\n protocol: 'https',\r\n hostname: 'images.ctfassets.net'\r\n },\r\n {\r\n protocol: 'https',\r\n hostname: 'rt-1-pr-euw-retailapis-end-01.azureedge.net'\r\n },\r\n {\r\n protocol: 'https',\r\n hostname: 'rt-1-dv-euw-retailapis-end-01.azureedge.net'\r\n },\r\n {\r\n protocol: 'https',\r\n hostname: 'sspayinaisledevsst02.blob.core.windows.net'\r\n }\r\n ]\r\n },\r\n headers: async () => {\r\n const headers = [\r\n {\r\n source: '/:path*',\r\n headers: [...allPathsHeaders, ...securityHeaders]\r\n }\r\n ];\r\n\r\n return headers;\r\n },\r\n modularizeImports: {\r\n lodash: {\r\n transform: 'lodash/{{member}}'\r\n }\r\n },\r\n // https://github.com/nexdrew/next-build-id\r\n // Base Next's build ID on Git info rather than a random string\r\n generateBuildId: () => nextBuildId({ dir: __dirname, describe: true }),\r\n webpack: (config, { webpack, buildId }) => {\r\n config.plugins.push(\r\n new webpack.DefinePlugin({\r\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/tree-shaking/\r\n __SENTRY_DEBUG__: false\r\n // __SENTRY_TRACING__: false\r\n }),\r\n new webpack.DefinePlugin({\r\n 'process.env.NEXT_PUBLIC_BUILD_ID': JSON.stringify(buildId),\r\n // eslint-disable-next-line n/no-process-env\r\n 'process.env.NEXT_PUBLIC_NODE_ENV': JSON.stringify(process.env.NODE_ENV)\r\n })\r\n );\r\n\r\n return config;\r\n },\r\n // Remove the x-powered-by header as some pentesters/scanners consider it an\r\n // information disclosure.\r\n poweredByHeader: false,\r\n eslint: {\r\n ignoreDuringBuilds: true\r\n },\r\n transpilePackages: [\r\n '@sindresorhus/slugify',\r\n 'escape-string-regexp',\r\n '@sindresorhus/transliterate'\r\n ],\r\n sentry: {\r\n hideSourcemaps: false\r\n }\r\n};\r\n\r\nmodule.exports = withSentryConfig(bundleAnalyzer(nextConfig), {\r\n silent: true\r\n});\r\n\r\n// module.exports = bundleAnalyzer(nextConfig);\r\n```\r\n\r\n### Steps to Reproduce\r\n\r\nI'm sorry, I don't have a minimum viable reproduction for this, and it's a private repo. I can try and put something together next week perhaps, but I wanted to raise this issue in case one of the maintainers recognised the issue.\r\n\r\nMy environment:\r\n\r\n```\r\n❯ npx next info\r\n\r\n Operating System:\r\n Platform: darwin\r\n Arch: x64\r\n Version: Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000\r\n Binaries:\r\n Node: 18.14.0\r\n npm: 9.6.4\r\n Yarn: N/A\r\n pnpm: 7.29.0\r\n Relevant Packages:\r\n next: 13.4.10\r\n eslint-config-next: 13.4.10\r\n react: 18.2.0\r\n react-dom: 18.2.0\r\n typescript: 5.1.6\r\n Next.js Config:\r\n output: N/A\r\n```\r\n\r\n### Expected Result\r\n\r\nSite can be viewed in dev mode\r\n\r\n### Actual Result\r\n\r\nSite errors when a page is viewed in dev mode when `withSentryConfig` is used, but works when `withSentryConfig` is not used. \r\n\r\n```\r\n- error TypeError: Cannot destructure property 'RawSource' of 'require(...)' as it is undefined.\r\n at @sentry/nextjs (/Users/wolsph/Projects/shop-next/.next/server/app/(main)/page.js:22:18)\r\n at __webpack_require__ (/Users/wolsph/Projects/shop-next/.next/server/webpack-runtime.js:33:43)\r\n at eval (./sentry.server.config.js:2:72)\r\n at (sc_server)/./sentry.server.config.js (/Users/wolsph/Projects/shop-next/.next/server/app/(main)/page.js:4643:1)\r\n at __webpack_require__ (/Users/wolsph/Projects/shop-next/.next/server/webpack-runtime.js:33:43)\r\n at eval (./src/app/layout.tsx:6:82)\r\n at (sc_server)/./src/app/layout.tsx (/Users/wolsph/Projects/shop-next/.next/server/app/(main)/page.js:1548:1)\r\n at Function.__webpack_require__ (/Users/wolsph/Projects/shop-next/.next/server/webpack-runtime.js:33:43)\r\n- error TypeError: Cannot destructure property 'RawSource' of 'require(...)' as it is undefined.\r\n at @sentry/nextjs (/Users/wolsph/Projects/shop-next/.next/server/app/(main)/page.js:22:18)\r\n at __webpack_require__ (/Users/wolsph/Projects/shop-next/.next/server/webpack-runtime.js:33:43)\r\n at eval (./sentry.server.config.js:2:72)\r\n at (sc_server)/./sentry.server.config.js (/Users/wolsph/Projects/shop-next/.next/server/app/(main)/page.js:4643:1)\r\n at __webpack_require__ (/Users/wolsph/Projects/shop-next/.next/server/webpack-runtime.js:33:43)\r\n at eval (./src/app/layout.tsx:6:82)\r\n at (sc_server)/./src/app/layout.tsx (/Users/wolsph/Projects/shop-next/.next/server/app/(main)/page.js:1548:1)\r\n at Function.__webpack_require__ (/Users/wolsph/Projects/shop-next/.next/server/webpack-runtime.js:33:43)\r\ndigest: \"1055278946\"\r\n- error Error [TypeError]: Cannot destructure property 'RawSource' of 'require(...)' as it is undefined.\r\n at Object.\u003canonymous> (/Users/wolsph/Projects/shop-next/node_modules/@sentry/webpack-plugin/src/index.js:5:9)\r\n at Module._compile (node:internal/modules/cjs/loader:1226:14)\r\n at Module._extensions..js (node:internal/modules/cjs/loader:1280:10)\r\n at Module.load (node:internal/modules/cjs/loader:1089:32)\r\n at Module._load (node:internal/modules/cjs/loader:930:12)\r\n at Module.require (node:internal/modules/cjs/loader:1113:19)\r\n at require (node:internal/modules/cjs/helpers:103:18)\r\n at Object.\u003canonymous> (/Users/wolsph/Projects/shop-next/node_modules/@sentry/webpack-plugin/src/cjs.js:1:18)\r\n at Module._compile (node:internal/modules/cjs/loader:1226:14)\r\n at Module._extensions..js (node:internal/modules/cjs/loader:1280:10)\r\n at Module.load (node:internal/modules/cjs/loader:1089:32)\r\n at Module._load (node:internal/modules/cjs/loader:930:12)\r\n at Module.require (node:internal/modules/cjs/loader:1113:19)\r\n at require (node:internal/modules/cjs/helpers:103:18)\r\n at Object.\u003canonymous> (/Users/wolsph/Projects/shop-next/node_modules/@sentry/nextjs/cjs/config/webpack.js:10:29)\r\n at Module._compile (node:internal/modules/cjs/loader:1226:14)\r\n at Module._extensions..js (node:internal/modules/cjs/loader:1280:10)\r\n at Module.load (node:internal/modules/cjs/loader:1089:32)\r\n at Module._load (node:internal/modules/cjs/loader:930:12)\r\n at Module.require (node:internal/modules/cjs/loader:1113:19)\r\n at require (node:internal/modules/cjs/helpers:103:18)\r\n at Object.\u003canonymous> (/Users/wolsph/Projects/shop-next/node_modules/@sentry/nextjs/cjs/config/withSentryConfig.js:7:17)\r\n at Module._compile (node:internal/modules/cjs/loader:1226:14)\r\n at Module._extensions..js (node:internal/modules/cjs/loader:1280:10)\r\n at Module.load (node:internal/modules/cjs/loader:1089:32)\r\n at Module._load (node:internal/modules/cjs/loader:930:12)\r\n at Module.require (node:internal/modules/cjs/loader:1113:19)\r\n at require (node:internal/modules/cjs/helpers:103:18)\r\n at Object.\u003canonymous> (/Users/wolsph/Projects/shop-next/node_modules/@sentry/nextjs/cjs/index.server.js:4:26)\r\n at Module._compile (node:internal/modules/cjs/loader:1226:14)\r\n at Module._extensions..js (node:internal/modules/cjs/loader:1280:10)\r\n at Module.load (node:internal/modules/cjs/loader:1089:32)\r\n at Module._load (node:internal/modules/cjs/loader:930:12)\r\n at Module.require (node:internal/modules/cjs/loader:1113:19)\r\n at require (node:internal/modules/cjs/helpers:103:18)\r\n at @sentry/nextjs (/Users/wolsph/Projects/shop-next/.next/server/app/(main)/page.js:22:18)\r\n at __webpack_require__ (/Users/wolsph/Projects/shop-next/.next/server/webpack-runtime.js:33:43)\r\n at eval (webpack-internal:///(sc_server)/./sentry.server.config.js:2:72)\r\n at (sc_server)/./sentry.server.config.js (/Users/wolsph/Projects/shop-next/.next/server/app/(main)/page.js:4643:1)\r\n at __webpack_require__ (/Users/wolsph/Projects/shop-next/.next/server/webpack-runtime.js:33:43)\r\n at eval (webpack-internal:///(sc_server)/./src/app/layout.tsx:6:82)\r\n at (sc_server)/./src/app/layout.tsx (/Users/wolsph/Projects/shop-next/.next/server/app/(main)/page.js:1548:1)\r\n at Function.__webpack_require__ (/Users/wolsph/Projects/shop-next/.next/server/webpack-runtime.js:33:43)\r\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\r\n at async /Users/wolsph/Projects/shop-next/node_modules/next/dist/server/app-render/app-render.js:1016:91 {\r\n digest: undefined\r\n}\r\n\r\n```","author":{"url":"https://github.com/philwolstenholme","@type":"Person","name":"philwolstenholme"},"datePublished":"2023-07-14T16:19:26Z","url":"https://github.com/getsentry/sentry-javascript/issues/8541"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:68b020db-5fcc-5eab-2d1c-28129c2218fc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C58:2E7DB9:410818:572AC9:6B04A037 |
| html-safe-nonce | 26e5d32fc215e8303c95ec419cc896505e343dd1e9aa6df9bbb6a4ca5a349839 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzU4OjJFN0RCOTo0MTA4MTg6NTcyQUM5OjZCMDRBMDM3IiwidmlzaXRvcl9pZCI6IjExMTQ4ODc3NDk5MzAwOTg3NDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6c2984a61362b48eb4d27ec403905e2f0bd6b75e989bffba555da7009765ff1e |
| hovercard-subject-tag | issue:1805135744 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/8541/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f0760bd5283ed3acbe3cd475387ecebb2585741f786f5a1e310046fac9384322/getsentry/sentry-javascript/issues/8541 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f0760bd5283ed3acbe3cd475387ecebb2585741f786f5a1e310046fac9384322/getsentry/sentry-javascript/issues/8541 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | philwolstenholme |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9784b6f42e2d5eac4e394fa88cad134c0dc5b6662b4ff2787a1ed1ef5a96331d |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3fd14143b75b2af7b76bbd23b069867d091adfcc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width