Skip to content

Circular dependency when building with sentry sveltekit #11553

Closed

Description

@sajaghori

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

7.109.0

Framework Version

SvelteKit 2.5.5, Vite 5.2.8

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

  1. Setup sentry sveltekit
  2. Use node adapter
  3. npm run build

Expected Result

No circular dependency

Actual Result

Using @sveltejs/adapter-node
Circular dependency: node_modules/@sentry/core/esm/hub.js -> node_modules/@sentry/core/esm/scope.js -> node_modules/@sentry/core/esm/utils/applyScopeDataToEvent.js -> node_modules/@sentry/core/esm/tracing/dynamicSamplingContext.js -> node_modules/@sentry/core/esm/exports.js -> node_modules/@sentry/core/esm/hub.js
Circular dependency: node_modules/@sentry/core/esm/scope.js -> node_modules/@sentry/core/esm/utils/applyScopeDataToEvent.js -> node_modules/@sentry/core/esm/tracing/dynamicSamplingContext.js -> node_modules/@sentry/core/esm/exports.js -> node_modules/@sentry/core/esm/utils/prepareEvent.js -> node_modules/@sentry/core/esm/scope.js
Circular dependency: node_modules/@sentry/core/esm/utils/applyScopeDataToEvent.js -> node_modules/@sentry/core/esm/tracing/dynamicSamplingContext.js -> node_modules/@sentry/core/esm/exports.js -> node_modules/@sentry/core/esm/utils/prepareEvent.js -> node_modules/@sentry/core/esm/utils/applyScopeDataToEvent.js

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 2on Apr 11, 2024
  2. Lms24 commented on Apr 11, 2024

    @Lms24
    Member

    Hey @sajaghori thanks for writing in! Yes, sadly there's a small circle in our import chain in the core package. We're resolving this in our new major version of the SDK (v8).

    Does this block you at the moment? Are you by chance using a strict tsconfig of some kind (skiplibcheck 👀 ) that surfaces this issue? We'll fix this but just wondering if you can work around it in the meantime.

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Apr 11, 2024
  4. sajaghori commented on Apr 16, 2024

    @sajaghori
    Author

    Hi @Lms24 thanks for the response! skiplibcheck does not work.
    I was looking for the reason why my vite dev server hangs sometimes. I can tell you that this circular dependency is not the root of cause. So feel free to close this or leave it open until you have v8 released.

  5. moved this to Waiting for: Product Owner in GitHub Issues with 👀 2on Apr 16, 2024
  6. Lms24 commented on Apr 16, 2024

    @Lms24
    Member

    Thanks for the update! The important thing is that you're not blocked by our SDK :)
    I'll leave this open for now until the circular dependency is resolved.

  7. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Apr 16, 2024
  8. added this to the 8.0.0 milestone on Apr 24, 2024
  9. Lms24 commented on Jun 4, 2024

    @Lms24
    Member

    Hi @sajaghori, we fixed the circular dependency in the core package in #12159. When you update to the latest v8 version of the SDK would you mind letting us know if this issue is fixed?

  10. moved this to Waiting for: Community in GitHub Issues with 👀 3on Jun 4, 2024
  11. sajaghori commented on Jun 4, 2024

    @sajaghori
    Author

    Hi @Lms24 yes, it works now with the latest version.
    However, keep in mind that the import line needed to be changed from import * as Sentry from '@sentry/sveltekit' to import Sentry from '@sentry/sveltekit'
    I think you need to adjust the setup wizard on your side, otherwise the integrations won't work.
    Thank you! Closing this issue.

  12. Lms24 commented on Jun 4, 2024

    @Lms24
    Member

    This is unexpected. The SDK should work with the namespace import, not the default import. That's how our SvelteKit E2E tests are set up (example). Does your setup look different from this? Also, does this apply to both, client and server side?

  13. sajaghori commented on Jun 4, 2024

    @sajaghori
    Author

    Exactly like your example in hooks.server.ts, but add this line in the init property
    integrations: [Sentry.httpIntegration()]

  14. sajaghori commented on Jun 4, 2024

    @sajaghori
    Author

    Also, does this apply to both, client and server side?

    No just server side with hooks.server.ts

  15. sajaghori commented on Jun 4, 2024

    @sajaghori
    Author

    You should get the error: TypeError: Sentry.httpIntegration is not a function
    with version: "@sentry/sveltekit": "^8.7.0",
    with hooks.server.ts:

    import * as Sentry from '@sentry/sveltekit'
    
    Sentry.init({
    		dsn: DSN,
    		tracesSampleRate: 1.0,
    		release: getVersion(),
    		environment: getEnvironment(),
    		// Add the Http integration for tracing
    		integrations: [Sentry.httpIntegration()]
    })
  16. Lms24 commented on Jun 4, 2024

    @Lms24
    Member

    Ahh I see, this is because we don't explicitly re-export httpIntegration from @sentry/sveltekit. I wonder why our export consistency check didn't catch this 😬

    May I ask why you want to initialize the integration manually? If you set debug: true, you should get a list of all integrations that are installed at SDK intialization. Http should be in this list by default.

    Regardless, the problem though is that I'm afraid, httpIntegration won't do much for SvelteKit because the hooks.server.js file is evaluated too late for opentelemetry instrumentation. This is sort of an open problem that affects multiple instrumentations. Haven't had much time to look into this yet but we definitely should soon.

  17. sajaghori commented on Jun 4, 2024

    @sajaghori
    Author

    Alright thank you for the insights. Would love to hear about improvements in the sveltekit sdk.

  18. 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

No one assigned

    Labels

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions