Skip to content

@sentry/sveltekit initCloudflareSentryHandle throws error when building/deploying to cloudflare pages #16613

Closed

Description

@matindow

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

Framework Version

@sveltejs/kit 2.21.5

Link to Sentry event

No response

Reproduction Example/SDK Setup

https://github.com/indowwindows/sentrysveltekittest

The reproduction uses cloudflare's wrangler pages dev command to trigger the error locally, but the same error occurs when deploying to cloudflare pages (cloudflare pages prevents the upload as a result of the issue).

The sentry setup is not "correct"/"complete" in the example, to illustrate the entry point for the issue (which appears to be the initCloudflareSentryHandle function in src/hooks.server.js).

Steps to Reproduce

pnpm run build
wrangler pages dev

Expected Result

should build/run/deploy without issue

Actual Result

When running wrangler pages dev the following error is thrown:

 ⛅️ wrangler 4.20.0
───────────────────
✘ [ERROR] Build failed with 1 error:

  ✘ [ERROR] Could not resolve "minimatch"

      ../output/server/chunks/hooks.server.js:24793:34:
        24793 │             globMatcher = require("minimatch").minimatch;
              ╵                                   ~~~~~~~~~~~

    You can mark the path "minimatch" as external to exclude it from the bundle, which will
  remove this error and leave the unresolved path in the bundle. You can also surround this
  "require" call with a try/catch block to handle this failure at run-time instead of
  bundle-time.





✘ [ERROR] Failed to build _worker.js.

This appears to be a result of a dependency on @fastify/otel that is not being correctly bundled: https://github.com/fastify/otel/blob/cef7fa5fd4726a1b6479dde726fa55ed3b1bd08c/index.js#L79
possibly related to isaacs/minimatch#257

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jun 16, 2025
  2. matindow commented on Jun 17, 2025

    @matindow
    Author

    Same issue with sentry 9.30.0 and wrangler 4.20.1. I have updated the dependencies in the example repo.

  3. teemingc commented on Jun 18, 2025

    @teemingc
    Contributor

    I'm so sorry, this one is my fault. We recently started bundling dependencies that declare a dependency on SvelteKit but that would mean the Node version of Sentry is getting bundled before the Wrangler bundling kicks in. This should be fixed when we merge sveltejs/kit#13894 to revert that bundling

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jun 18, 2025
  5. mydea commented on Jun 18, 2025

    @mydea
    Member

    @eltigerchino thanks for the update 🙏 can you let us know when this is merged/released? Thank you!

  6. teemingc commented on Jun 18, 2025

    @teemingc
    Contributor

    Sure thing! In the meantime, if you want to avoid downgrading your packages, the very simple workaround is to add @sentry/sveltekit to the ssr.external option in vite.config.ts to prevent Vite from bundling it in.
    sveltejs/kit#13869 (comment)

  7. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jun 18, 2025
  8. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jun 18, 2025
  9. 4 remaining items

  10. self-assigned this
    on Jul 8, 2025
  11. teemingc commented on Jul 8, 2025

    @teemingc
    Contributor

    @eltigerchino do you have an estimation when sveltejs/kit#13894 will be merged?

    I think it's mostly complete. cc: @elliott-with-the-longest-name-on-github is there anything else we need to do before marking it as ready or to merge it?

  12. moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 8, 2025
  13. teemingc commented on Jul 9, 2025

    @teemingc
    Contributor

    sveltejs/kit#13971 should fix this as well

  14. Lms24 commented on Jul 9, 2025

    @Lms24
    Member

    Nice, thanks for the update! 🙏

  15. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 9, 2025
  16. teemingc commented on Jul 10, 2025

    @teemingc
    Contributor
  17. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 10, 2025
  18. Lms24 commented on Jul 10, 2025

    @Lms24
    Member

    Thanks for shipping this @eltigerchino!

    Can confirm that the newest Kit version works again in the repro from #16818 (cc @RaniSputnik).

    Closing this for the moment, please let us know if anyone still experiences a problem!

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

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions