Skip to content

Sentry with async function nextConfig not working #7444

Description

@AbhiPrasad

Discussed in #7433

Originally posted by Supermog March 13, 2023
So I have a project that I added Sentry to, but the problem is that I have the nextConfig variable as an async function which the withSentryConfig doesn't accept. My next.config.js file looks like this:

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

const prismic = require('@prismicio/client');

const sm = require('./sm.json');

/** @type {import('next').NextConfig} */
const nextConfig = async () => {
  const client = prismic.createClient(sm.apiEndpoint);

  const repository = await client.getRepository();
  const locales = repository.languages.map(lang => lang.id);

  return {
    reactStrictMode: true,
    swcMinify: true,
    compiler: {
      styledComponents: true,
    },
    i18n: {
      // These are all the locales you want to support in
      // your application
      locales: locales,
      // This is the default locale you want to be used when visiting
      // a non-locale prefixed path e.g. `/hello`
      defaultLocale: locales[0],
      localeDetection: false,
    },
  };
};

module.exports = withSentryConfig(
  nextConfig,
  { silent: true },
  { hideSourcemaps: true },
);

I've also played around with it and using await on the nextConfig argument or calling the function also does not work. I've tried converting it to .then blocks but that also does not work.
Without Sentry it works well because nextjs accepts nextConfig as an async function but Sentry does not. Is there a workaround to this?

"@sentry/nextjs": "^7.42.0",
"next": "13.1.2",
"react": "18.2.0",

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions