getsentry / profiling-node

The code for this repo now lives in https://github.com/getsentry/sentry-javascript/tree/develop/packages/profiling-node
MIT License
28 stars 10 forks source link

Module parse failed: Unexpected character '�' (1:0) #170

Open haydenbleasel opened 1 year ago

haydenbleasel commented 1 year ago

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?

How is your code deployed and bundled?

Standard Next.js build process running on Vercel. Here's the abstracted next.config.js:

import { withSentryConfig } from '@sentry/nextjs';

/** @type {import('next').NextConfig} */
const nextConfig = {
  async rewrites() {
    return [
      {
        source: '/api/sentry/:path*',
        destination:
          'https://{x}.ingest.sentry.io/api/{y}/envelope/',
      },
    ];
  },
  sentry: {
    hideSourceMaps: true,
    tunnelRoute: '/api/sentry',
  },
};

/** @type {import('@sentry/nextjs').SentryWebpackPluginOptions} */
const sentryWebpackPluginOptions = {
  silent: true,
};

export default withSentryConfig(
  sentryWebpackPluginOptions
);

Steps to Reproduce

Following the installation instructions in the Sentry web UI, updated my sentry.server.config.js to the following:

import * as Sentry from '@sentry/nextjs';
import { ProfilingIntegration } from '@sentry/profiling-node';

Sentry.init({
  dsn: process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN
  tracesSampleRate: 1.0,
  profilesSampleRate: 1.0,
  integrations: [
    new ProfilingIntegration(),
  ],
});

Deploy to Vercel which runs npm build.

Potential follow-on issue from #164

Expected Result

The build should pass.

Actual Result

19:12:21.256 |  Failed to compile.
19:12:21.256 |  
19:12:21.256 | ./node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-93.node
19:12:21.256 | Module parse failed: Unexpected character '�' (1:0)
19:12:21.256 | 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
19:12:21.257 | (Source code omitted for this binary file)
19:12:21.257 |  
19:12:21.257 | Import trace for requested module:
19:12:21.257 | ./node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-93.node
19:12:21.257 | ./node_modules/@sentry/profiling-node/lib/index.js
19:12:21.257 | ./sentry.server.config.js
19:12:21.257 | ./app/layout.tsx
19:12:21.257 |  
19:12:21.257 | ./node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-108.node
19:12:21.257 | Module parse failed: Unexpected character '�' (1:0)
19:12:21.257 | 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
19:12:21.257 | (Source code omitted for this binary file)
19:12:21.257 |  
19:12:21.257 | Import trace for requested module:
19:12:21.257 | ./node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-108.node
19:12:21.257 | ./node_modules/@sentry/profiling-node/lib/index.js
19:12:21.257 | ./sentry.server.config.js
19:12:21.258 | ./app/layout.tsx
19:12:21.258 |  
19:12:21.258 | ./node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-linux-arm64-glibc-83.node
19:12:21.258 | Module parse failed: Unexpected character '' (1:0)
19:12:21.258 | 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
19:12:21.259 | (Source code omitted for this binary file)
19:12:21.259 |  
19:12:21.259 | Import trace for requested module:
19:12:21.259 | ./node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-linux-arm64-glibc-83.node
19:12:21.259 | ./node_modules/@sentry/profiling-node/lib/index.js
19:12:21.259 | ./sentry.server.config.js
19:12:21.259 | ./app/layout.tsx
19:12:21.259 |  
19:12:21.259 | ./node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-linux-arm64-glibc-93.node
19:12:21.259 | Module parse failed: Unexpected character '' (1:0)
19:12:21.259 | 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
19:12:21.259 | (Source code omitted for this binary file)
19:12:21.259 |  
19:12:21.259 | Import trace for requested module:
19:12:21.260 | ./node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-linux-arm64-glibc-93.node
19:12:21.260 | ./node_modules/@sentry/profiling-node/lib/index.js
19:12:21.260 | ./sentry.server.config.js
19:12:21.260 | ./app/layout.tsx
19:12:21.260 |  
19:12:21.260 | ./node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-linux-arm64-glibc-108.node
19:12:21.260 | Module parse failed: Unexpected character '' (1:0)
19:12:21.260 | 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
19:12:21.260 | (Source code omitted for this binary file)
19:12:21.260 |  
19:12:21.260 | Import trace for requested module:
19:12:21.260 | ./node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-linux-arm64-glibc-108.node
19:12:21.260 | ./node_modules/@sentry/profiling-node/lib/index.js
19:12:21.260 | ./sentry.server.config.js
19:12:21.260 | ./app/layout.tsx
19:12:21.260 |  
19:12:21.260 |  
19:12:21.260 | > Build failed because of webpack errors
JonasBa commented 1 year ago

@haydenbleasel you need to define a loader for .node files. This seems like it uses webpack and not turbopack so https://webpack.js.org/loaders/node-loader/ should be the correct way to go. A quick search reveals this comment from nextjs team which explains how to set this up https://github.com/vercel/next.js/discussions/34040#discussioncomment-4904466

doinki commented 1 year ago

@JonasBa I have completed the node-loader setup, but the following warning appears when building.

../../node_modules/.pnpm/@sentry+profiling-node@1.0.7/node_modules/@sentry/profiling-node/lib/index.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
../../node_modules/.pnpm/@sentry+profiling-node@1.0.7/node_modules/@sentry/profiling-node/lib/index.js
./sentry.server.config.ts
./src/app/layout.tsx
kachar commented 1 year ago

We're experiencing this problem as well.

yarnPath: .yarn/releases/yarn-3.6.0.cjs with .pnp.cjs

    "@sentry/core": "^7.57.0",
    "@sentry/nextjs": "^7.57.0",
    "@sentry/profiling-node": "^1.0.8",
    "@sentry/utils": "^7.57.0",
    "next": "13.4.4",

Here are our build logs when we try to use Next.js with App Router

- warn Fast Refresh had to perform a full reload. Read more: https://nextjs.org/docs/messages/fast-refresh-reload
- wait compiling...
- error ./.yarn/unplugged/@sentry-profiling-node-npm-1.0.8-6c9dd4d639/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:
./.yarn/unplugged/@sentry-profiling-node-npm-1.0.8-6c9dd4d639/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-108.node
./.yarn/unplugged/@sentry-profiling-node-npm-1.0.8-6c9dd4d639/node_modules/@sentry/profiling-node/lib/ sync ^\.\/sentry_cpu_profiler\-.*\.node$
./.yarn/unplugged/@sentry-profiling-node-npm-1.0.8-6c9dd4d639/node_modules/@sentry/profiling-node/lib/index.js
./sentry.server.config.ts
./app/[orgSlug]/[thread]/page.tsx
- wait compiling /_error (client and server)...
- error ./.yarn/unplugged/@sentry-profiling-node-npm-1.0.8-6c9dd4d639/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-108.node
JonasBa commented 1 year ago

I'm looking into this issue today, from what I can tell, the message you see at build time Critical dependency: the request of a dependency is an expression is only a warning and should not affect loading. That said, I have changed the module loading to no longer be async and removed the expression from require which I'm hoping will suppress this.

JonasBa commented 1 year ago

@doinki the warning is unfortunate, but I don't think we can get rid of this without breaking support for folks who don't use bundlers (which is a lot of nodejs application).

The reason you see the warning is because in cases where we do not find the prebuild binary for the target arch, we default to the version which was built from source - this way users on older/newer versions of nodejs or some "non standard" arch can still use the package. The problem is that we do not know all the possible permutations of those target environments, which means they are not statically analyzable by bundlers and hence cannot be hardcoded in the list.

Our binary loading logic handled this by having a default case in the switch platform/arch/node version (see cpu_profiler.ts), but here is a contrived example...

 switch (platform) {
    case 'darwin': {
      switch (arch) {
        case 'x64': {
          switch (abi) {
            case '93': {
              return require('./sentry_cpu_profiler-darwin-x64-93.node');
            }
            case '108': {
              return require('./sentry_cpu_profiler-darwin-x64-108.node');
            }
          }
        }
        ...other platform/arch/node versions
        If a user is in neither of the above permutations, fallthrough to the default require which
        attempts to load the binary that was built from source at install time.
        default: {
           require(path_to_binary_built_from_source) // <--- this is why you are seeing the warning
         }

So as you see, if we remove the require expression, we end up breaking support for everyone not in the hardcoded list, which we don't want to do. This is unfortunate and I agree, annoying, but I would rather deal with a warning than breaking the package. That said, I am going to try and see if I can use the contextReplacementPlugin from webpack to silence this warning.

JonasBa commented 1 year ago

@doinki I will try to see if we can silence these warnings in the next version of the package.

@kachar, do you mind setting up the loader and seeing if you encounter the same issue?

karamgaby commented 11 months ago

same problem happening with the following packages

 "@prisma/client": "^4.15.0",
    "@sentry/nextjs": "^7.59.3",
    "@sentry/profiling-node": "^1.1.2",
    "next": "13.4.4",
JonasBa commented 11 months ago

@karamgaby can you share the error you are seeing? There are different errors in this issue - if you are only seeing a warning Critical dependency: the request of a dependency is an expression then you should ignore it, as I described in my comment, removing it would break support for every platform/arch that we do not provide precompiled binaries for.

If the error you are seeing is

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

then you need to ensure your build system knows how to handle .node files. You can either configure a loader or mark the package as external (see our guide on bundling)

mmahalwy commented 10 months ago

@JonasBa mind providing an example with how this would work with vercel ncc? I cannot get this to work with webpack and nextjs as an external

Maxim-Mazurok commented 10 months ago

This worked for me:

next.config.js:

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    serverActions: true,
  },
  webpack: (config) => {
    config.externals = {
      "@sentry/profiling-node": "commonjs @sentry/profiling-node", // fixes https://github.com/getsentry/profiling-node/issues/170
    };
    return config;
  },
};

module.exports = nextConfig;

// Injected content via Sentry wizard below
// ...

Not really, next dev works, but prod build fails to pre-render

JonasBa commented 10 months ago

@mmahalwy we have a section on bundlers in our readme, you can see how to configure it there https://github.com/getsentry/profiling-node#bundling

@Maxim-Mazurok what is the error that you see at build time?

Maxim-Mazurok commented 10 months ago
npm run build

> router-handling@0.1.0 build
> next build

Failed to compile.

./node_modules/next/dist/compiled/next-server/pages.runtime.prod.js:1:32489
Module not found: Can't resolve 'critters'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/next/dist/server/future/route-modules/pages/module.compiled.js

> Build failed because of webpack errors
   Creating an optimized production build .

So I did npm i critters

And now I get this:

npm run build

> router-handling@0.1.0 build
> next build

 ⚠ Compiled with warnings

./node_modules/next/dist/compiled/@ampproject/toolbox-optimizer/index.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/next/dist/compiled/@ampproject/toolbox-optimizer/index.js
./node_modules/next/dist/compiled/next-server/pages.runtime.prod.js
./node_modules/next/dist/server/future/route-modules/pages/module.compiled.js

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./Box' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./ClickAwayListener' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./CssBaseline' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./darkScrollbar' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./Fade' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./Grow' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./Hidden' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./MenuList' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./NoSsr' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./Popper' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./Portal' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./RadioGroup' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./Slide' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./Stack' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./SwipeableDrawer' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./TextareaAutosize' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./useMediaQuery' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./usePagination' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./useScrollTrigger' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./Zoom' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./GlobalStyles' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=useTheme&wildcard!=!./generateUtilityClass' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Paper,Table,TableBody,TableCell,TableContainer,TableHead,TableRow,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/compareTable.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./Box' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./ClickAwayListener' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./CssBaseline' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./darkScrollbar' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./Fade' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./Grow' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./Hidden' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./MenuList' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./NoSsr' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./Popper' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./Portal' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./RadioGroup' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./Slide' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./Stack' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./SwipeableDrawer' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./TextareaAutosize' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./useMediaQuery' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./usePagination' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./useScrollTrigger' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./Zoom' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./GlobalStyles' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
The requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./generateUtilityClass' contains conflicting star exports for the name '__esModule' with the previous requested module '__barrel_optimize__?names=autocompleteClasses,styled,useTheme&wildcard!=!./utils'

Import trace for requested module:
__barrel_optimize__?names=Popper,Typography,autocompleteClasses,styled,useMediaQuery,useTheme!=!./node_modules/@mui/material/index.js
./app/utils/virtualizedInput.tsx
./app/compareForm.tsx
./app/home.tsx
./app/page.tsx

./node_modules/retry-request/index.js
Module not found: Can't resolve 'request' in '/home/maxim/my-project/node_modules/retry-request'

Import trace for requested module:
./node_modules/retry-request/index.js
./node_modules/google-gax/build/src/streamingCalls/streaming.js
./node_modules/google-gax/build/src/index.js
./node_modules/@googlemaps/routing/build/src/v2/routes_client.js
./node_modules/@googlemaps/routing/build/src/v2/index.js
./node_modules/@googlemaps/routing/build/src/index.js
./app/api/compare/route.ts

 ✓ Linting and checking validity of types   
 ✓ Collecting page data   
   Generating static pages (1/6) [=   ] 
TypeError: Cannot read properties of null (reading 'useContext')
    at ei.useContext (/home/maxim/my-project/.next/server/chunks/871.js:49:188589)
    at eb (/home/maxim/my-project/.next/server/chunks/871.js:36:24272)
    at eE (/home/maxim/my-project/.next/server/chunks/871.js:36:14841)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:141914)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:156001)
    at aa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:141462)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:142065)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:144318)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:156001)
    at ca (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:158062)
TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/maxim/my-project/.next/server/chunks/992.js:9:5495)
    at m (/home/maxim/my-project/.next/server/chunks/172.js:1:4501)
    at Wc (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
    at Zc (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
    at Z (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
    at $c (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
    at bd (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
    at Z (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
    at $c (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
    at Zc (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:71:145)
TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/maxim/my-project/.next/server/chunks/992.js:9:5495)
    at m (/home/maxim/my-project/.next/server/chunks/172.js:1:4501)
    at Wc (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
    at Zc (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
    at Z (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
    at $c (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
    at bd (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
    at Z (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
    at $c (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
    at Zc (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:71:145)

Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/maxim/my-project/.next/server/chunks/992.js:9:5495)
    at m (/home/maxim/my-project/.next/server/chunks/172.js:1:4501)
    at Wc (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
    at Zc (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
    at Z (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
    at $c (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
    at bd (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
    at Z (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
    at $c (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
    at Zc (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:71:145)

Error occurred prerendering page "/500". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (/home/maxim/my-project/.next/server/chunks/992.js:9:5495)
    at m (/home/maxim/my-project/.next/server/chunks/172.js:1:4501)
    at Wc (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
    at Zc (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
    at Z (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
    at $c (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
    at bd (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
    at Z (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
    at $c (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
    at Zc (/home/maxim/my-project/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:71:145)
TypeError: Cannot read properties of null (reading 'useContext')
    at ei.useContext (/home/maxim/my-project/.next/server/chunks/871.js:49:188589)
    at eb (/home/maxim/my-project/.next/server/chunks/871.js:36:24272)
    at eE (/home/maxim/my-project/.next/server/chunks/871.js:36:14841)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:141914)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:156001)
    at aa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:141462)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:142065)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:144318)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:156001)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:156228)

Error occurred prerendering page "/_not-found". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of null (reading 'useContext')
    at ei.useContext (/home/maxim/my-project/.next/server/chunks/871.js:49:188589)
    at eb (/home/maxim/my-project/.next/server/chunks/871.js:36:24272)
    at eE (/home/maxim/my-project/.next/server/chunks/871.js:36:14841)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:141914)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:156001)
    at aa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:141462)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:142065)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:144318)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:156001)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.pro
   Generating static pages (5/6) [==  ] 
   Creating an optimized production build ...TypeError: Cannot read properties of null (reading 'useContext')
    at ei.useContext (/home/maxim/my-project/.next/server/chunks/871.js:49:188589)
    at eb (/home/maxim/my-project/.next/server/chunks/871.js:36:24272)
    at eE (/home/maxim/my-project/.next/server/chunks/871.js:36:14841)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:141914)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:156001)
    at aa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:141462)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:142065)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:144318)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:156001)
    at ca (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.pro
   Generating static pages (5/6) [=== ] 
TypeError: Cannot read properties of null (reading 'useContext')
    at ei.useContext (/home/maxim/my-project/.next/server/chunks/871.js:49:188589)
    at eb (/home/maxim/my-project/.next/server/chunks/871.js:36:24272)
    at eE (/home/maxim/my-project/.next/server/chunks/871.js:36:14841)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:141914)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:156001)
    at aa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:141462)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:142065)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:144318)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:156001)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:156228)

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of null (reading 'useContext')
    at ei.useContext (/home/maxim/my-project/.next/server/chunks/871.js:49:188589)
    at eb (/home/maxim/my-project/.next/server/chunks/871.js:36:24272)
    at eE (/home/maxim/my-project/.next/server/chunks/871.js:36:14841)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:141914)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:156001)
    at aa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:141462)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:142065)
    at sa (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:144318)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js:1:156001)
    at ia (/home/maxim/my-project/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.pro
 ✓ Generating static pages (6/6)

> Export encountered errors on following paths:
        /_error: /404
        /_error: /500
        /_not-found
        /page: /
   Creating an optimized production build .

I've tried using latest stable next, and here's the next config:

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    serverActions: true,
  },
  webpack: (config) => {
    config.externals = {
      "@sentry/profiling-node": "commonjs @sentry/profiling-node", // fixes https://github.com/getsentry/profiling-node/issues/170
    };
    return config;
  },
};

module.exports = nextConfig;

// Injected content via Sentry wizard below

const { withSentryConfig } = require("@sentry/nextjs");

module.exports = withSentryConfig(
  module.exports,
  {
    // For all available options, see:
    // https://github.com/getsentry/sentry-webpack-plugin#options

    // Suppresses source map uploading logs during build
    silent: true,
    org: "travel-times",
    project: "javascript-nextjs",
  },
  {
    // For all available options, see:
    // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/

    // Upload a larger set of source maps for prettier stack traces (increases build time)
    widenClientFileUpload: true,

    // Transpiles SDK to be compatible with IE11 (increases bundle size)
    transpileClientSDK: true,

    // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
    tunnelRoute: "/monitoring",

    // Hides source maps from generated client bundles
    hideSourceMaps: true,

    // Automatically tree-shake Sentry logger statements to reduce bundle size
    disableLogger: true,
  }
);

my next setup is pretty vanilla, using app router.

sentry configs also pretty much as wizard created them:

// This file configures the initialization of Sentry on the client.
// The config you add here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from "@sentry/nextjs";

Sentry.init({
  dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
  environment: process.env.NEXT_PUBLIC_ENVIRONMENT_NAME,

  // Adjust this value in production, or use tracesSampler for greater control
  tracesSampleRate: 1,

  // Setting this option to true will print useful information to the console while you're setting up Sentry.
  debug: false, // need to change `disableLogger` in next config to make this work

  replaysOnErrorSampleRate: 1.0,

  // This sets the sample rate to be 10%. You may want this to be 100% while
  // in development and sample at a lower rate in production
  replaysSessionSampleRate: 0.1,

  // You can remove this option if you're not planning to use the Sentry Session Replay feature:
  integrations: [
    new Sentry.Replay({
      // Additional Replay configuration goes in here, for example:
      // maskAllText: true,
      // blockAllMedia: true,
    }),
  ],
});

etc, hope it helps.

I decided to defer node profiling, it's not very important for me at this stage of the project.

JonasBa commented 10 months ago

@Maxim-Mazurok, that is very weird. We do not use the critters package so it's unclear to me why this happens.

The error I'm seeing seems like a nextj react prerender error unrelated to @sentry/profiling-node

Creating an optimized production build ...TypeError: Cannot read properties of null (reading 'useContext')
    at ei.useContext (/home/maxim/my-project/.next/server/chunks/871.js:49:188589)

I'm going to try and setup a nextjs app and see if I can reproduce

Maxim-Mazurok commented 10 months ago

I also use MUI components and most of my components are "use client"; if that makes a difference... Overall I feel like nextjs is doing so much magic under the hood that the errors I'm getting on the way make very little sense, maybe it's just because it's my first nextjs project.

Maxim-Mazurok commented 10 months ago

Related to critters: https://github.com/vercel/next.js/issues/34763

nhewage1997 commented 9 months ago

Hi I wanted to reopen this thread.

I'm trying to setup profiling for my next.js application. I modified sentry.server.config.ts with the following


profilesSampleRate: 1.0,
integrations: [
newProfilingIntegration(),
]

and have the following sentry versions defined:

"@sentry/integrations": "^7.74.1",
"@sentry/nextjs": "^7.74.1",
"@sentry/profiling-node": "^1.2.1",
"@sentry/types": "^7.74.1",

. This causes my build to fail with the following error:

./node_modules/.pnpm/@sentry+profiling-node@1.2.1/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/.pnpm/@sentry+profiling-node@1.2.1/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-93.node
./node_modules/.pnpm/@sentry+profiling-node@1.2.1/node_modules/@sentry/profiling-node/lib/index.js
./sentry.server.config.ts
./app/page.tsx

./node_modules/.pnpm/@sentry+profiling-node@1.2.1/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/.pnpm/@sentry+profiling-node@1.2.1/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-108.node
./node_modules/.pnpm/@sentry+profiling-node@1.2.1/node_modules/@sentry/profiling-node/lib/index.js
./sentry.server.config.ts
./app/page.tsx

./node_modules/.pnpm/@sentry+profiling-node@1.2.1/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/.pnpm/@sentry+profiling-node@1.2.1/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-115.node
./node_modules/.pnpm/@sentry+profiling-node@1.2.1/node_modules/@sentry/profiling-node/lib/index.js
./sentry.server.config.ts
./app/page.tsx

./node_modules/.pnpm/@sentry+profiling-node@1.2.1/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-83.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/.pnpm/@sentry+profiling-node@1.2.1/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-83.node
./node_modules/.pnpm/@sentry+profiling-node@1.2.1/node_modules/@sentry/profiling-node/lib/index.js
./sentry.server.config.ts
./app/page.tsx

./node_modules/.pnpm/@sentry+profiling-node@1.2.1/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/.pnpm/@sentry+profiling-node@1.2.1/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-93.node
./node_modules/.pnpm/@sentry+profiling-node@1.2.1/node_modules/@sentry/profiling-node/lib/index.js
./sentry.server.config.ts
./app/page.tsx

I saw this related thread and added the following line to my next.config.js file:

config.externals = {
'@sentry/profiling-node':'commonjs @sentry/profiling-node',
}

and then installed critters but then received the following error:


SyntaxError: Unexpected identifier
--
14:05:12.695 | at internalCompileFunction (node:internal/vm:73:18)
14:05:12.695 | at wrapSafe (node:internal/modules/cjs/loader:1178:20)
14:05:12.695 | at Module._compile (node:internal/modules/cjs/loader:1220:27)
14:05:12.695 | at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
14:05:12.695 | at Module.load (node:internal/modules/cjs/loader:1119:32)
14:05:12.695 | at Module._load (node:internal/modules/cjs/loader:960:12)
14:05:12.695 | at Module.require (node:internal/modules/cjs/loader:1143:19)
14:05:12.695 | at mod.require (/vercel/path0/node_modules/.pnpm/next@13.5.3_@babel+core@7.23.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/require-hook.js:64:28)
14:05:12.695 | at require (node:internal/modules/cjs/helpers:121:18)
14:05:12.695 | at t.f.require (/vercel/path0/.next/server/webpack-runtime.js:1:1515) {
14:05:12.695 | type: 'SyntaxError'```

which wasn't very illustrative. I was wondering if there were any ideas on how to handle this.

tua-Mascot commented 8 months ago

@nhewage1997 I have the same problem. Haven't you fixed it yet? @JonasBa Can you help with such a problem? My errors during production build are the same as @nhewage1997 (almost 1 to 1).

Versions:

"next": "^13.5.4",
"@sentry/nextjs": "^7.77.0",
"@sentry/profiling-node": "^1.2.6",
JonasBa commented 8 months ago

@nhewage1997 you shouldn't need to install critters for this to work. Do you mind uninstalling it and telling me if it still fails?

@tua-Mascot can you please share a relevant stack trace and confirm that you marked @sentry/profiling-node as an external module?

pablo-leone-realstocks commented 8 months ago

I have the same issue when trying to integrate profiling in a nestjs project in mono-repo mode. Adding the package as external does not work. I removed profiling for now until the issue is fixed.

tua-Mascot commented 8 months ago

@JonasBa Sure

Stack trace

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/not-found.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/not-found.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/not-found.tsx

./node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-x64-83.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-83.node
./node_modules/@sentry/profiling-node/lib/index.js
./sentry.server.config.ts
./src/app/not-found.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/not-found.tsx

> Build failed because of webpack errors

And I added this to next.config.js

experimental: {
    serverComponentsExternalPackages: ['@sentry/profiling-node']
  },

I can provide some additional information:

tua-Mascot commented 8 months ago

@JonasBa Sorry to bother you, but more than a week has passed. Are there any updates/news?

JonasBa commented 8 months ago

@tua-Mascot mind creating a reproducible case for this? I think that adding your component to external packages didn't work as the build system is still trying to resolve that file

florianjuengermann commented 8 months ago

I have the same issue, when marking it as external I'm missing the "critters" package.

anonrig commented 7 months ago

Here's a reproducible case for this issue. Checking out this commit produces the following error. Ref: https://github.com/anonrig/yagiz.co/commit/ef3c8afe923f573f83b30190937cccf36e2d2ac5

./node_modules/.pnpm/@sentry+profiling-node@1.2.6/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)
anonrig commented 7 months ago

Adding serverComponentsExternalPackages: ['@sentry/profiling-node'], seems to fix the issue for Next.js 14. Which document do you import/require @sentry/profiling-node package? It should be inside sentry.server.{js,ts}

smozely commented 7 months ago

Getting this error as well on a new project with Sentry setup.

I've tried doing ... serverComponentsExternalPackages: ['@sentry/profiling-node'] in the next config, but hasn't changed anything.

Key relevant packages

"next": "^14.0.4",
"@sentry/nextjs": "^7.88.0",
"@sentry/profiling-node": "^1.3.2",

Happy to try and provide more info if that will help, otherwise disabling profiling for the time being

Simplest repro: https://github.com/Starter4Ten/Sentry-NextJS-Explore/releases/tag/server-profile-issue

npm install
npm run build
jiushiwoyuze commented 6 months ago

Is there any update? Meet the same issue.ServerComponentsExternalPackages only works for development, still get error when building. image

JesseKoldewijn commented 6 months ago

@nikolovlazar This is something I just ran into. Which is the issue I mentioned during the webinar just now. I also don't know why it's trying to read the darwin file instead of linux to be honest. Maybe thats the issue?

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Mon Nov 6 23:32:38 UTC 2023
Binaries:
  Node: 20.10.0
  npm: 10.2.3
  Yarn: 1.22.21
  pnpm: 8.14.1

I'm running Arch under wsl2 and when adding the profiling integration I got greeted with the following error:

./node_modules/.pnpm/@sentry+profiling-node@1.3.5_@sentry+node@7.92.0/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/.pnpm/@sentry+profiling-node@1.3.5_@sentry+node@7.92.0/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-93.node
./node_modules/.pnpm/@sentry+profiling-node@1.3.5_@sentry+node@7.92.0/node_modules/@sentry/profiling-node/lib/index.js
./sentry.server.config.ts
./src/app/page.tsx

repo: https://github.com/JesseKoldewijn/JKinsight

anonrig commented 6 months ago

@JesseKoldewijn Your Next.js config file does not have experimental.serverComponentsExternalPackages attribute. Ref: https://github.com/getsentry/profiling-node#bundling

JesseKoldewijn commented 6 months ago

@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 commented 6 months ago

@anonrig the external package config fixed the issue for me indeed. Must have either missed this in the docs within the sentry UI or it wasn't mentioned in there at all. If this fix could globally fix this for more sentry+next users I could open another PR on Next to auto include this package in the exclude list (done this before with a couple of packages)

anonrig commented 6 months ago

@anonrig the external package config fixed the issue for me indeed. Must have either missed this in the docs within the sentry UI or it wasn't mentioned in there at all. If this fix could globally fix this for more sentry+next users I could open another PR on Next to auto include this package in the exclude list (done this before with a couple of packages)

That would be a good idea. Thanks!

JonasBa commented 6 months ago

@JesseKoldewijn that would be a very good idea, thank you for proposing that. P.S: I'm happy to open the PR, I didn't think NextJS would allow something like that and was under the impression they'd want developers to manage this on their own

JesseKoldewijn commented 6 months ago

Im opening an issue on Next.js's side already and added package to this list in the 13.x releases as well. so I prob got the PR up in a couple of minutes 👍

JesseKoldewijn commented 6 months ago

Issue created: https://github.com/vercel/next.js/issues/60853

JesseKoldewijn commented 6 months ago

PR is open, lets see when it will be merged. Also noticed that this wasn't the first sentry package in there funny enough 😉

JesseKoldewijn commented 6 months ago

Just woke up and saw that the fix was merged into the canary branch of Next.js🤙

JesseKoldewijn commented 6 months ago

Incase anybody wants to bypass setting the experimental config entry in Next.js already and is fine with using the canary channel of Next.js you can already use the fix I pushed through the PR by upgrading to Next.js release v14.1.1-canary.1

JesseKoldewijn commented 6 months ago

Is there any update? Meet the same issue.ServerComponentsExternalPackages only works for development, still get error when building. image

I've personally tested using the integration with external package enabled which worked perfectly. Could you possibly check if the issue on your end persists if you upgrade Next.js to the latest canary release?

ps. this can be done by targeting the following install directive next@canary

JonasBa commented 6 months ago

Part of what is frustrating with this issue is that many folks run this through platforms that largely abstract build configurations while also building and executing your code for different environments (example is server vs edge) and depending on their versions, they might even use different underlying build tools. The result of this is that many folks are not aware of how their code is built (rightfully so as tools should just work) or how their code is executed at runtime, leaving library maintainers largely in a bit of a tough spot to debug.

When you see an error like Module parse failed: Unexpected character '�' (1:0), it means your build tooling is not configured to recognize the file as binary and attempts to read it as utf8. Since it fails to make sense of the binary data as utf8, it will display the unicode replacement character � and correctly error.

Marking packages as external fixes this as it instructs the bundler to skip such files and instead require them at runtime, and while this does work, it leaves you without the realizing the gains that bundles code has on your script cold start performance (something highly relevant to something like profiling where we want to keep the runtime impact minimal)

In other words, by requiring packages marked as external, the module loader needs to perform additional disk i/o to be able to evaluate the module and execute it, which impacts cold start performance. AWS has a good article on optimizing cold start performance in serverless that I recommend reading.

All this to say that when you do encounter issues like this, you should check with your platform provider or your bundler configuration if it is possible to bundle packages containing binary files as it will both make your code faster to run as well as save you some infra costs.

JonasBa commented 6 months ago

I forgot to add that in order to mitigate the impact on your cold start performance when @sentry/profiling-node is marked as external, we publish the library as a single index.js executable where all of its dependencies are bundled. This way, even if you mark the library as external, the module loader is only executed once for the @sentry/profiling-node module js file and once to load the binary file.

tua-Mascot commented 6 months ago

@JonasBa Unfortunately, in my case the problem is still reproducible. I checked on two versions of next.js - 14.1.0 and 14.1.1-canary.4

I made a fresh repository with next.config.js and sentry configs are close to the settings in my project. If we add "use client" to the very top of the page.tsx file, then we get (probably) the same error

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
./app/page.tsx

But if you delete the "use client", then everything works.

Link to the repository - https://github.com/tua-Mascot/sentry-profiling-node-test

JesseKoldewijn commented 6 months ago

@JonasBa Unfortunately, in my case the problem is still reproducible. I checked on two versions of next.js - 14.1.0 and 14.1.1-canary.4

I made a fresh repository with next.config.js and sentry configs are close to the settings in my project. If we add "use client" to the very top of the page.tsx file, then we get (probably) the same error

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
./app/page.tsx

But if you delete the "use client", then everything works.

Link to the repository - https://github.com/tua-Mascot/sentry-profiling-node-test

In that case it crashes because the "use client" flag indicates that the component also has to run in de browser. Due to this flag the component wont be using the external package config or the Next.js internal packages list.

Its kinda the same problem as when you try to run native node.js modules in the browser.

tua-Mascot commented 6 months ago

@JesseKoldewijn Thank you for the clarification. But I didn't fully understand. Does this mean that I can't use "use client" if I want to use @sentry/profiling-node?

JesseKoldewijn commented 6 months ago

@JesseKoldewijn

Thank you for the clarification. But I didn't fully understand. Does this mean that I can't use "use client" if I want to use @sentry/profiling-node?

If you only use the node-profiler within a server action, you can. Otherwise, you can't. Since a client component runs as mentioned before both on the server and client👍

Slyracoon23 commented 6 months ago

@JesseKoldewijn Thank you for the clarification. But I didn't fully understand. Does this mean that I can't use "use client" if I want to use @sentry/profiling-node?

If you only use the node-profiler within a server action, you can. Otherwise, you can't. Since a client component runs as mentioned before both on the server and client👍

Is there a going to be a fix in the future for support for the 'use client' directive for the nextjs app router in the future for profiling?

JesseKoldewijn commented 6 months ago

@JesseKoldewijn

Thank you for the clarification. But I didn't fully understand. Does this mean that I can't use "use client" if I want to use @sentry/profiling-node?

If you only use the node-profiler within a server action, you can. Otherwise, you can't. Since a client component runs as mentioned before both on the server and client👍

Is there a going to be a fix in the future for support for the 'use client' directive for the nextjs app router in the future for profiling?

The node profiler is not intended to run on the client since the browser doesn't run node. So as long as you exclude it from running on the client it might run fine in client components.

jiushiwoyuze commented 5 months ago

@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",

JesseKoldewijn commented 5 months ago

@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?

jiushiwoyuze commented 5 months ago

@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 image

And I found there are confilts during install, because @sentry/next need a peerDependence for nextjs highest 14.0. image So maybe sentry do not fully support next14.1 right now.