Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nuxt): Add warning when Netlify or Vercel build is discovered #13868

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions packages/nuxt/src/module.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also be great if we could detect when users actually set up everything correctly for the respective platform and not show the warning in that case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm...one thing we could do is getting the NODE_OPTIONS variable and check if the file path is correct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good idea.

Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ export default defineNuxtModule<ModuleOptions>({
});
}

consoleSandbox(() => {
const serverDir = nitro.options.output.serverDir;

// Netlify env: https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
if (serverDir.includes('.netlify') || !!process.env.NETLIFY) {
// eslint-disable-next-line no-console
console.warn(
'[Sentry] Warning: The Sentry SDK detected a Netlify build. Server-side support for the Sentry Nuxt SDK on Netlify is currently unreliable due to technical limitations of serverless functions. Traces are not collected, and errors may occasionally not be reported. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/',
);
}

// Vercel env: https://vercel.com/docs/projects/environment-variables/system-environment-variables#VERCEL
if (serverDir.includes('.vercel') || !!process.env.VERCEL) {
// eslint-disable-next-line no-console
console.warn(
'[Sentry] Warning: The Sentry SDK detected a Vercel build. The Sentry Nuxt SDK currently does not support tracing on Vercel. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/',
);
}
});

if (moduleOptions.autoInjectServerSentry !== 'experimental_dynamic-import') {
addServerConfigToBuild(moduleOptions, nuxt, nitro, serverConfigFile);

Expand Down
Loading