Open haydenbleasel opened 1 year ago
Just to add to this, I also have the same issue. I tried fixing it by following the various recommendations you gave :
Added the following snippet to next.config.js
{
experimental: {
serverComponentsExternalPackages: [
'@sentry/profiling-node',
],
},
}```
I still get the same errors as before :
Failed to compile.
../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-93.node
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
Import trace for requested module:
../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-93.node
../../node_modules/@sentry/profiling-node/lib/index.js
./sentry.server.config.ts
./src/app/(auth)/layout.tsx
../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-108.node
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
Import trace for requested module:
../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-108.node
../../node_modules/@sentry/profiling-node/lib/index.js
./sentry.server.config.ts
./src/app/(auth)/layout.tsx
../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-115.node
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
Import trace for requested module:
../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-115.node
../../node_modules/@sentry/profiling-node/lib/index.js
./sentry.server.config.ts
./src/app/(auth)/layout.tsx
../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-93.node
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
Import trace for requested module:
../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-93.node
../../node_modules/@sentry/profiling-node/lib/index.js
./sentry.server.config.ts
./src/app/(auth)/layout.tsx
../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-108.node
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
Import trace for requested module:
../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-108.node
../../node_modules/@sentry/profiling-node/lib/index.js
./sentry.server.config.ts
./src/app/(auth)/layout.tsx
> Build failed because of webpack errors
I also use MUI components, so I got 'use client';
basically everywhere.
@JesseKoldewijn Your Next.js config file does not have experimental.serverComponentsExternalPackages attribute. Ref: https://github.com/getsentry/profiling-node#bundling
Ah check. Thanks, will check if that's the fix later today👌
@JesseKoldewijn Unfortunately, not work for me. Here is the verison I used "@sentry/nextjs": "7.92.0", "@sentry/profiling-node": "^1.3.5", "next": "^14.1.1-canary.25",
Are you using the node profiler in a client component by chance?
@JesseKoldewijn No, I use the default setting in my sentry.server.config file only. As the code below
And I found there are confilts during install, because @sentry/next need a peerDependence for nextjs highest 14.0. So maybe sentry do not fully support next14.1 right now.
As mentioned before, the package does work in Next.js 14.1.1-canary.1 and later. But without a reproduction repo and only the server config file I can't really make an educated guess on why it doesn't work in your project.
Just to add to this, I also have the same issue. I tried fixing it by following the various recommendations you gave :
- Upgrade Next from 13.4.9 to 14.1.0
- Upgrade Node to 18.17.0 (Next 14 requirement)
Added the following snippet to
next.config.js
{ experimental: { serverComponentsExternalPackages: [ '@sentry/profiling-node', ], }, }``` I still get the same errors as before :
Failed to compile. ../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-93.node Module parse failed: Unexpected character '�' (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders (Source code omitted for this binary file) Import trace for requested module: ../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-93.node ../../node_modules/@sentry/profiling-node/lib/index.js ./sentry.server.config.ts ./src/app/(auth)/layout.tsx ../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-108.node Module parse failed: Unexpected character '�' (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders (Source code omitted for this binary file) Import trace for requested module: ../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-108.node ../../node_modules/@sentry/profiling-node/lib/index.js ./sentry.server.config.ts ./src/app/(auth)/layout.tsx ../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-115.node Module parse failed: Unexpected character '�' (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders (Source code omitted for this binary file) Import trace for requested module: ../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-115.node ../../node_modules/@sentry/profiling-node/lib/index.js ./sentry.server.config.ts ./src/app/(auth)/layout.tsx ../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-93.node Module parse failed: Unexpected character '�' (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders (Source code omitted for this binary file) Import trace for requested module: ../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-93.node ../../node_modules/@sentry/profiling-node/lib/index.js ./sentry.server.config.ts ./src/app/(auth)/layout.tsx ../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-108.node Module parse failed: Unexpected character '�' (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders (Source code omitted for this binary file) Import trace for requested module: ../../node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-108.node ../../node_modules/@sentry/profiling-node/lib/index.js ./sentry.server.config.ts ./src/app/(auth)/layout.tsx > Build failed because of webpack errors
I also use MUI components, so I got
'use client';
basically everywhere.
Could you provide me with a reproduction repo by chance? Since I don't know where you import the profiling-node package right now.
To anybody with this issue past next release 14.1.1-canary.1 please check out my repo below which is a working example of the fix within nextjs I've implemented.
I had similar issues but running Node 18, Express.js, and Webpack. I was able to get passed the Unexpected character '�' (1:0)
issue by adding @sentry/profiling-node': 'commonjs @sentry/profiling-node
to externals
in webpack.config.js
.
...
module.exports = {
entry: './src/index.ts',
externals: {
'@sentry/profiling-node': 'commonjs @sentry/profiling-node',
},
devtool: 'inline-source-map',
target: 'node',
module: {
rules: [
...
But now I'm experiencing a new error message that I have not figure out how to resolve during webpack build. Does any have any suggestions?
...
webpack://eh-replicache-api/node_modules/@sentry/profiling-node/lib/index.js:652
const DEBUG_BUILD$1 = __DEBUG_BUILD__;
^
ReferenceError: __DEBUG_BUILD__ is not defined
at Object../node_modules/@sentry/profiling-node/lib/index.js (webpack://eh-replicache-api/node_modules/@sentry/profiling-node/lib/index.js:652:1)
at __webpack_require__ (webpack://eh-replicache-api/webpack/bootstrap:19:1)
at Object../src/utils/sentry/initSentry.ts (webpack://eh-replicache-api/src/utils/sentry/initSentry.ts:2:1)
at __webpack_require__ (webpack://eh-replicache-api/webpack/bootstrap:19:1)
at Object../src/index.ts (webpack://eh-replicache-api/src/index.ts:16:1)
at __webpack_require__ (webpack://eh-replicache-api/webpack/bootstrap:19:1)
at <anonymous> (webpack://eh-replicache-api/webpack/startup:4:1)
at Object.<anonymous> (webpack://eh-replicache-api/webpack/startup:4:1)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
I've ran into a similar issue.
Tried to add
{
experimental: {
serverComponentsExternalPackages: [
'@sentry/profiling-node',
],
},
}
Which works as long as I don't have a use client
component.
I'm in
"next": "^14.1.3",
"@sentry/browser": "^7.106.1",
"@sentry/nextjs": "^7.106.0",
"@sentry/node": "^7.106.1",
"@sentry/profiling-node": "^7.106.1",
Wondering if there is a way to only enable the Profiling in the pages
router and disable it in the app
router?
I've ran into a similar issue.
Tried to add
{ experimental: { serverComponentsExternalPackages: [ '@sentry/profiling-node', ], }, }
Which works as long as I don't have a
use client
component. I'm in"next": "^14.1.3", "@sentry/browser": "^7.106.1", "@sentry/nextjs": "^7.106.0", "@sentry/node": "^7.106.1", "@sentry/profiling-node": "^7.106.1",
Wondering if there is a way to only enable the Profiling in the
pages
router and disable it in theapp
router?
Are you importing the @sentry/profiling-node package inside a component which is marked with "use client"? Because this will not work due to the component also runs in the browser.
I've ran into a similar issue. Tried to add
{ experimental: { serverComponentsExternalPackages: [ '@sentry/profiling-node', ], }, }
Which works as long as I don't have a
use client
component. I'm in"next": "^14.1.3", "@sentry/browser": "^7.106.1", "@sentry/nextjs": "^7.106.0", "@sentry/node": "^7.106.1", "@sentry/profiling-node": "^7.106.1",
Wondering if there is a way to only enable the Profiling in the
pages
router and disable it in theapp
router?Are you importing the @sentry/profiling-node package inside a component which is marked with "use client"? Because this will not work due to the component also runs in the browser.
Thank you @JesseKoldewijn . Sorry for my late response as well.
We don't import @sentry/profiling-node package in any specific component. This is how we configured Sentry Profiling. We only has the import in the config files. I guess this enables the profiling for all components?
// sentry.server.config.ts
import * as Sentry from '@sentry/nextjs';
import { ProfilingIntegration } from '@sentry/profiling-node';
Sentry.init({
profilesSampleRate: 1,
integrations: [new ProfilingIntegration()],
});
// sentry.client.config.ts
import * as Sentry from '@sentry/nextjs';
Sentry.init({
profilesSampleRate: 1,
integrations: [
new Sentry.BrowserProfilingIntegration(),
],
});
// next.config.mjs
import { withSentryConfig } from '@sentry/nextjs';
export default withSentryConfig({
headers: async () => {
return [
{
source: "/(.*)",
headers: [
{
key: "Document-Policy",
value: "js-profiling"
}
]
}
]
},
});
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
SDK Version
1.0.7
Link to Sentry event
No response
What environment is your node script running in?
"@sentry/nextjs": "^7.57.0"
How is your code deployed and bundled?
Standard Next.js build process running on Vercel. Here's the abstracted
next.config.js
:Steps to Reproduce
Following the installation instructions in the Sentry web UI, updated my
sentry.server.config.js
to the following:Deploy to Vercel which runs
npm build
.Potential follow-on issue from #164
Expected Result
The build should pass.
Actual Result