Skip to content

upgrading to v9 caused a ERR_REQUIRE_CYCLE_MODULE #15363

Closed

Description

@tcurdt

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/vite@6.1.0_@types+node@22.13.1_jiti@1.21.7_yaml@2.7.0/node_modules/vite/dist/node/index.js in a cycle. (from backend/node_modules/.pnpm/@sentry+sveltekit@9.0.0_@opentelemetry+api@1.9.0_@opentelemetry+context-async-hooks@1.3_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)

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Feb 10, 2025
  2. andreiborza commented on Feb 11, 2025

    @andreiborza
    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?

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Feb 11, 2025
  4. tcurdt commented on Feb 11, 2025

    @tcurdt
    Author

    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?

  5. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Feb 11, 2025
  6. andreiborza commented on Feb 11, 2025

    @andreiborza
    Member
  7. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Feb 11, 2025
  8. jamesbirtles commented on Feb 11, 2025

    @jamesbirtles

    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

  9. 2 remaining items

  10. tcurdt commented on Feb 11, 2025

    @tcurdt
    Author

    @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
    
    > 15363-sveltekit@0.0.1 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/vite@6.1.0_@types+node@22.13.1/node_modules/vite/dist/node/index.js in a cycle. (from /Users/tcurdt/Downloads/15363-sveltekit/node_modules/.pnpm/@sentry+sveltekit@9.0.0_@opentelemetry+api@1.9.0_@opentelemetry+context-async-hooks@1.3_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.
    
  11. tcurdt commented on Feb 11, 2025

    @tcurdt
    Author

    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.

  12. Lms24 commented on Feb 11, 2025

    @Lms24
    Member

    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.

  13. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Feb 11, 2025
  14. Lms24 commented on Feb 11, 2025

    @Lms24
    Member

    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.

  15. tcurdt commented on Feb 11, 2025

    @tcurdt
    Author

    Thanks for the quick help.

  16. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Feb 11, 2025
  17. self-assigned this
    on Feb 11, 2025
  18. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Feb 11, 2025
  19. Lms24 commented on Feb 17, 2025

    @Lms24
    Member

    #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)

  20. ghost added on Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions