You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sentry for Nextjs messes up the build process #6472
I'm using Rive for animations, and in order to not download their runtime (wasm) from the CDN, I use the following article methodology. The gist of it is the following webpack config in next.config:
When I updated sentry to the latest version (7.24.1) next build gives the following error:
web:build: Failed to compile.
web:build:
web:build: ./node_modules/@rive-app/canvas/rive.wasm
web:build: Module parse failed: Unexpected character '' (1:0)
web:build: The module seem to be a WebAssembly module, but module is not flagged as WebAssembly module for webpack.
web:build: BREAKING CHANGE: Since webpack 5 WebAssembly is not enabled by default and flagged as experimental feature.
web:build: You need to enable one of the WebAssembly experiments via 'experiments.asyncWebAssembly: true' (based on async modules) or 'experiments.syncWebAssembly: true' (like webpack 4, deprecated).
web:build: For files that transpile to WebAssembly, make sure to set the module type in the 'module.rules' section of the config (e. g. 'type: "webassembly/async"').
web:build: (Source code omitted for this binary file)
Since everything worked as expected with 7.16.0, I downgraded back and there was no build error. I am not able to further narrow down the version in which this error appears atm.
Expected Result
Sentry shouldn't mess with the rest of my build process, the url-loader for the Rive runtime shouldn't error in the build.
Hi, can you please share your complete Next.js config? Even better would be a reproduction example we can pull to try to reproduce the error ourselves.
// @ts-checkconst{ withSentryConfig }=require('@sentry/nextjs');constnextSafe=require('next-safe');constnextTranslate=require('next-translate');const{ defaultLocale, locales }=require('./i18n');// @ts-ignoreconstwithRoutes=require('nextjs-routes/config')({outDir: 'types',i18n: {
defaultLocale,
locales,},});constwithBundleAnalyzer=require('@next/bundle-analyzer');constpackageJson=require('./package.json');// @ts-ignoreconstsecureHeaders=nextSafe({isDev: process.env.NODE_ENV!=='production',contentSecurityPolicy: false,// Will be dynamically set in the apppermissionsPolicyDirectiveSupport: [],// TODO: create a reasonable permission policy});/** * Generics are necessary here in order to narrow down properties (publicRuntimeConfig for example) * * @template {import('next').NextConfig} T * @param {T} config - A generic parameter that flows through to the return type * @constraint {{import('next').NextConfig}} */functiongetConfig(config){returnconfig;}/** * @param {string} name * @returns string | null */functiongetEnv(name){returnprocess.env[name]??'!!missing!!';}letconfig=getConfig({// trailingSlash: true,optimizeFonts: false,reactStrictMode: true,poweredByHeader: false,images: {formats: ['image/avif','image/webp'],},httpAgentOptions: {keepAlive: false,},// EnvironmentserverRuntimeConfig: {},publicRuntimeConfig: {appName: packageJson.name,appVersion: packageJson.version,appEnv: getEnv('APP_ENV'),},// SWCswcMinify: true,compiler: {// emotion: true by default since 12.2.0},experimental: {legacyBrowsers: false,browsersListForSwc: true,esmExternals: true,},asyncheaders(){return[{source: '/(.*)',headers: secureHeaders},]},sentry: {// Use `hidden-source-map` rather than `source-map` as the Webpack `devtool`// for client-side builds. (This will be the default starting in// `@sentry/nextjs` version 8.0.0.) See// https://webpack.js.org/configuration/devtool/ and// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map// for more information.hideSourceMaps: true,disableServerWebpackPlugin: !process.env['SENTRY_SOURCE_MAPS_UPLOAD'],disableClientWebpackPlugin: !process.env['SENTRY_SOURCE_MAPS_UPLOAD'],},webpack: (config,{ webpack, isServer })=>{if(!isServer){// Fixes npm packages that depend on `fs` module// @link https://github.com/vercel/next.js/issues/36514#issuecomment-1112074589config.resolve.fallback={ ...config.resolve.fallback,fs: false};}// https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/tree-shaking/config.plugins.push(newwebpack.DefinePlugin({__SENTRY_DEBUG__: process.env['NODE_ENV']!=='production',__SENTRY_TRACING__: true,// TODO: remove if not used? Big bundle chunk}));config.module.rules.push({test: /\.wasm$/,use: ['url-loader'],});returnconfig;},});// Disable sentry for dev mode and local buildsif(process.env['NODE_ENV']==='production'&&config.publicRuntimeConfig.appEnv!=='development'){/** * @link https://github.com/getsentry/sentry-webpack-plugin#options * @type {Partial<import("@sentry/nextjs/types/config/types").SentryWebpackPluginOptions>} */constsentryConfig={// Additional config options for the Sentry Webpack plugin. Keep in mind that// the following options are set automatically, and overriding them is not// recommended:// release, url, org, project, authToken, configFile, stripPrefix,// urlPrefix, include, ignoresilent: false,// Don't suppresses logs// dryRun: true,};// @ts-ignoreconfig=withSentryConfig(config,sentryConfig);console.info('Sentry On!');}if(process.env['ANALYZE']==='true'){config=withBundleAnalyzer({enabled: true,})(config);}/** * @module next.config * @type {config} */// @ts-ignoremodule.exports=withRoutes(nextTranslate(config));
Hi, please refer to this issue or this one as to why your Next.js config doesn't work anymore. withSentryConfig() may return a function (I recommend you remove the ts-ignore).
Hi @lforst , sorry for the late response. The links you provided, unfortunately, don't address the problem and didn't help. I'll try to create a sandbox for reproduction as soon as I manage.
In the meantime, I'll stick with the 7.16.0 version since it's the last that still works.
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
Activity
lforst commentedon Dec 8, 2022
Hi, can you please share your complete Next.js config? Even better would be a reproduction example we can pull to try to reproduce the error ourselves.
filipjakov commentedon Dec 9, 2022
@lforst here is the config:
lforst commentedon Dec 9, 2022
Hi, please refer to this issue or this one as to why your Next.js config doesn't work anymore.
withSentryConfig()may return a function (I recommend you remove thets-ignore).filipjakov commentedon Dec 20, 2022
Hi @lforst , sorry for the late response. The links you provided, unfortunately, don't address the problem and didn't help. I'll try to create a sandbox for reproduction as soon as I manage.
In the meantime, I'll stick with the 7.16.0 version since it's the last that still works.
github-actions commentedon Jan 11, 2023
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it
Status: BacklogorStatus: In Progress, I will leave it alone ... forever!"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀