Skip to content

upgrading to v9 caused a ERR_REQUIRE_CYCLE_MODULE #15363

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

Closed
3 tasks done
tcurdt opened this issue Feb 10, 2025 · 11 comments
Closed
3 tasks done

upgrading to v9 caused a ERR_REQUIRE_CYCLE_MODULE #15363

tcurdt opened this issue Feb 10, 2025 · 11 comments
Assignees
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK

Comments

@tcurdt
Copy link

tcurdt commented Feb 10, 2025

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/sveltekit

SDK Version

9.0.0

Framework Version

Sveltekit 2.17.1

Link to Sentry event

No response

Reproduction Example/SDK Setup

import { sentrySvelteKit } from '@sentry/sveltekit';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';

export default defineConfig({
  plugins: [
    sentrySvelteKit({
      sourceMapsUploadOptions: {
        org: '****',
        project: '****',
        telemetry: false
      }
    }),
    sveltekit()
  ],
  test: {
    include: ['src/**/*.{test,spec}.{js,ts}']
  },
  build: {
    rollupOptions: {
      output: {
        manualChunks: (id) => {
          if (id.includes('layerchart')) return 'layerchart';
          if (id.includes('tiptap')) return '@tiptap/core';
        }
      }
    }
  }
});

Steps to Reproduce

The upgrade to v9 broke our build. We had to revert backt o v8.

Expected Result

It to just build like it did with v8.

Actual Result

failed to load config from backend/vite.config.ts
error during build:
Error [ERR_REQUIRE_CYCLE_MODULE]: Cannot require() ES Module backend/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/vite/dist/node/index.js in a cycle. (from backend/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_eade410b93e85394cc20b647e788e9c4/node_modules/@sentry/sveltekit/build/cjs/vite/sourceMaps.js)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:352:15)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1554:24)
    at Module._compile (node:internal/modules/cjs/loader:1705:5)
    at Object..js (node:internal/modules/cjs/loader:1888:10)
    at Module.load (node:internal/modules/cjs/loader:1458:32)
    at Function._load (node:internal/modules/cjs/loader:1275:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:234:24)
    at Module.require (node:internal/modules/cjs/loader:1480:12)
    at require (node:internal/modules/helpers:135:16)
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Feb 10, 2025
@github-actions github-actions bot added the Package: sveltekit Issues related to the Sentry SvelteKit SDK label Feb 10, 2025
@andreiborza
Copy link
Member

Hi @tcurdt, thank you for writing in.

I tried to reproduce this with a fresh sveltekit starter project with your config (although I noticed sveltekit() is missing in your plugins array) but didn't run into this issue.

Could you please provide a reproduction repo?

@tcurdt
Copy link
Author

tcurdt commented Feb 11, 2025

Hi @tcurdt, thank you for writing in.

I tried to reproduce this with a fresh sveltekit starter project with your config (although I noticed sveltekit() is missing in your plugins array) but didn't run into this issue.

I removed a comment and by mistake also removed the sveltekit() plugin.
Fixed that in the ticket. Sorry about that.

Could you please provide a reproduction repo?

Hm. I'll try.

Could you share the project files of your starter project? Just so we are using off the same project?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Feb 11, 2025
@andreiborza
Copy link
Member

@tcurdt sure, here's my repo: https://github.com/andreiborza/15363-sveltekit

@jamesbirtles
Copy link

jamesbirtles commented Feb 11, 2025

I am also running into this issue. I tried cloning your repo @andreiborza and get the same problem:

Image

Node version v22.13.1 if it helps

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Feb 11, 2025
@jamesbirtles
Copy link

So on a hunch I moved the import { defineConfig } from 'vitest/config'; (or in my repo import { defineConfig } from "vite";) line to be the first import and this fixed the problem!

@tcurdt
Copy link
Author

tcurdt commented Feb 11, 2025

@tcurdt sure, here's my repo: https://github.com/andreiborza/15363-sveltekit

I can actually reproduce it with your repo, @andreiborza

No changes.

$ pnpm run build

> [email protected] build /Users/tcurdt/Downloads/15363-sveltekit
> vite build

failed to load config from /Users/tcurdt/Downloads/15363-sveltekit/vite.config.ts
error during build:
Error [ERR_REQUIRE_CYCLE_MODULE]: Cannot require() ES Module /Users/tcurdt/Downloads/15363-sveltekit/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index.js in a cycle. (from /Users/tcurdt/Downloads/15363-sveltekit/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_517a6e19df8bfe93bf5414be54f13244/node_modules/@sentry/sveltekit/build/cjs/vite/sourceMaps.js)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:352:15)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1554:24)
    at Module._compile (node:internal/modules/cjs/loader:1705:5)
    at Object..js (node:internal/modules/cjs/loader:1888:10)
    at Module.load (node:internal/modules/cjs/loader:1458:32)
    at Function._load (node:internal/modules/cjs/loader:1275:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:234:24)
    at Module.require (node:internal/modules/cjs/loader:1480:12)
    at require (node:internal/modules/helpers:135:16)
 ELIFECYCLE  Command failed with exit code 1.

@tcurdt
Copy link
Author

tcurdt commented Feb 11, 2025

So on a hunch I moved the import { defineConfig } from 'vitest/config'; (or in my repo import { defineConfig } from "vite";) line to be the first import and this fixed the problem!

I still need to try that on our main repo - but it fixes the test repo.
Good find. But also scary sneaky.

@Lms24
Copy link
Member

Lms24 commented Feb 11, 2025

This error appears with Node 22.12.0 and onwards, and most probably is related to "require ESM". We'll look into it.

In the meantime, to unblock yourselves, you can use Node 22.11.0 or below or version 8 of the SDK.

UPDATE: This is likely related to #14886 where we introduced a possible require cycle by importing the vite config within our plugin. I will attempt to confirm this and keep you all posted once we know more.

@Lms24
Copy link
Member

Lms24 commented Feb 11, 2025

I could confirm that our import of vite during sentrySvelteKit Vite plugin creation causes this cyclic import. While we would only once import this (and thus not cause an actual infinite cycle), Node can't know this and fails.

I tested this a bit and for now, it seems like I can use a dynamic await import(vite') instead. Opened #15371 and once CI is happy with this change I'll merge it. Sorry for the troubles everyone! We'll likely cut a new release in the next days to get this fix out.

@tcurdt
Copy link
Author

tcurdt commented Feb 11, 2025

Thanks for the quick help.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Feb 11, 2025
@Lms24 Lms24 self-assigned this Feb 11, 2025
@Lms24
Copy link
Member

Lms24 commented Feb 17, 2025

#15371 was merged and released with 9.1.0. Closing this issue. Please let me know if this issue persists (I'm aware of #15414 btw but it's not the same problem)

@Lms24 Lms24 closed this as completed Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK
Projects
Archived in project
Development

No branches or pull requests

4 participants