Skip to content

Errors with ky / globalThis.fetch when trying to upgrade @sentry/nextjs > 7.29.0: typeerror, cannot read properties of undefined (reading 'bind') #7070

Closed as not planned
@shouze

Description

@shouze

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/nextjs

SDK Version

7.36.0

Framework Version

nextjs 13.1.6

Link to Sentry event

No response

SDK Setup

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

const nextConfig = () => {
  const IBE_ENV = readEnvironmentVariable("IBE_ENV", "production");
  if (!["development", "test", "staging", "production"].includes(IBE_ENV)) {
    throw new Error(
      `The environment variable "IBE_ENV" should have one the value: "development", "test", "staging", "production". Current value: "${IBE_ENV}"`,
    );
  }

  return {
    compress: false,
    modularizeImports: {
      "date-fns": {
        transform: "date-fns/{{member}}",
        preventFullImport: true,
      },
    },
    reactStrictMode: true,
    experimental: {
      swcPlugins: [
        ["next-superjson-plugin", {}],
        ["@lingui/swc-plugin", {}],
        [
          "@swc/plugin-styled-components",
          {
            displayName: true,
            ssr: true,
          },
        ],
      ],
    },
    compiler: {
      styledComponents: {
        displayName: true,
        ssr: true,
      },
    },
    env: {
      APP_ENV,
    }
    i18n: {
      locales: locales,
      defaultLocale: "fr",
    },
    pageExtensions: ["page.tsx", "page.ts", "page.jsx", "page.js", "api.ts"],
    productionBrowserSourceMaps: APP_ENV !== "production",
    eslint: {
      ignoreDuringBuilds: true,
    },
    typescript: {
      ignoreBuildErrors: true,
    },
    sentry: {
      hideSourceMaps: APP_ENV === "production",
      widenClientFileUpload: true,
    },
  };
};


const sentryWebpackPluginOptions = {
  silent: true, // Suppresses all logs
  // For all available options, see:
  // https://github.com/getsentry/sentry-webpack-plugin#options.
};

module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);

Steps to Reproduce

yarn run test

Produces such errors when (using ky 0.33.2):

TypeError: Cannot read properties of undefined (reading 'bind')
          at new bind (/home/sebastien/src/guest-journey.backup/internet-booking-engine/node_modules/ky/distribution/core/Ky.js:124:54)

Was working up to version 7.29.0 of @sentry/nextjs. Any upgrade generate such errors.
Using nodejs 16.x at the moment.

Expected Result

No errors, like with SDK <= 7.29.0

Actual Result

 TypeError: Cannot read properties of undefined (reading 'bind')
          at new bind (/src/my-app/node_modules/ky/distribution/core/Ky.js:124:54)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions