Open Palmaswell opened 1 month ago
Hi, can you try and make out from the stack trace and maybe with source map where this error comes from? A way to reproduce this somehow would also be awesome! Thanks!
Hi @lforst, thanks so much for you prompt reply.
I tried vizualizing the stack trace for the TypeError [ERR_INVALID_ARG_TYPE]
error. As you can see in the images below the error orginates in the @opentelemetry/instrumentation/build/esm/instrumentation.js
in the runSpanCustomizationHook
and ends in Node's resolve/lib/core
as effectively shown in the source map vizualization it receives path.dirname(96184)
. I hope this can help us get any further.
Below the images from top to bottom like in the stack trace:
at 765218 (/Users/mau/Repos/Squads/squads/apps/web/.next/server/chunks/3426.js:157:349959)
at 841124 (/Users/mau/Repos/Squads/squads/apps/web/.next/server/chunks/3426.js:157:345522)
at 530195 (/Users/mau/Repos/Squads/squads/apps/web/.next/server/chunks/3426.js:157:342144)
at 110401 (/Users/mau/Repos/Squads/squads/apps/web/.next/server/chunks/3426.js:6:14780
Please let me know anything else I can do to solve the issue.
Thanks a bunch for providing the resolved code! I think all frames except for the top one resolved weirdly though. I don't have a solution to this yet but this seems like a buggy mixture of opentelemetry/webpack to me. Webpack seems to be turning require.resolve('is-core-module/package.json')
into 96184
.
Do you have any other plugins/configurations that may influence module resolution? Maybe something like a json file resolver?
Please take a look at our Next.js config below. The only thing I can think about is the config resolve fallback we currently require for an NPM module.
import { withSentryConfig } from "@sentry/nextjs";
import { createVanillaExtractPlugin } from "@vanilla-extract/next-plugin";
const withVanillaExtract = createVanillaExtractPlugin({
outputCss: true,
});
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
transpilePackages: ["@squads/ui"],
experimental: {
instrumentationHook: true,
serverComponentsExternalPackages: ["@sentry/profiling-node"],
},
images: {
remotePatterns: [
{
protocol: "https",
hostname: "**",
},
],
},
redirects: async () => {
return [{ source: "/", destination: "/squads", permanent: true }];
},
webpack: (config, { nextRuntime, isServer }) => {
if (nextRuntime === "edge") {
// This is equivalent to { fallback: {"node:crypto": false} }
config.externals.push({
"node:crypto": "{}",
stream: "{}",
});
}
config.externals.push({
"@sentry/profiling-node": "commonjs @sentry/profiling-node",
});
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
};
}
return config;
},
};
export default withSentryConfig(
withVanillaExtract(nextConfig),
{ authToken: process.env.SENTRY_AUTH_TOKEN, silent: true },
{ hideSourceMaps: true }
);
Hey @Palmaswell, unfortunately our NextJS experts are out for a couple of days but we'll take another detailed look on Monday (cc @lforst and @s1gr1d and sorry for the ping 😬).
Just an observation: Looks like you added the third parameter to withSentryConfig
again which won't have an effect for v8. You should move the option to the 2nd parameter although this probably won't fix the issue.
I honestly don't know what is going on here. Would you mind sharing a reproduction example? Something feels off, considering the source maps are also broken.
Hi @lforst, what do you mean by a reproduction example? I would appreciate it if you could be more specific. Thanks again.
@Palmaswell Ideally something like a Repo we can pull or a Stackblitz where we can reproduce this error with clear instructions.
Unfortunately, I can't share the repo as it's private for the organization I work for. I will prepare a reproduction on Stackblitz in the next couple of days.
@Palmaswell did y'all ever figure out a fix for this? I'm having this on a brand new repo.
@cvoege would you mind sharing something we can use to reproduce locally?
@Palmaswell did y'all ever figure out a fix for this? I'm having this on a brand new repo.
No, we were not able to fix this yet. It would be really great if you could share the team so they can reproduce.
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
8.7.0
Framework Version
@sentry/nextjs@^8.7.0", @sentry/node@^8.7.0, @sentry/profiling-node@^8.7.0
Link to Sentry event
No response
SDK Setup
Client
Instrumentation.ts
Next.JS Config
Steps to Reproduce
With meticulous attention, I diligently followed all the steps outlined in the documentation to address the issue.
withSentryConfig
in the Next.js config, as it now only accepts two arguments.next build.
Running dev was still possible, though,next start.
Expected Result
I expect to successfully upgrade the three packages and start and build the Next.js package as usual.
Actual Result
I continuously get the same error when running a
next build
.Please note that I also tried:
@sentry/profiling-node
package.yarn.lock
file, all without success.