Skip to content

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

Closed
@matindow

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

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Waiting for: Product Owner

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions