Skip to content

Build Error in SvelteKit with Cloudflare Pages Following Cloudflare SvelteKit Framework Guide #13976

Closed
@onursoyer

Description

@onursoyer

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/cloudflare

SDK Version

8.34.0

Framework Version

SvelteKit 2.7.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

import { sequence } from "@sveltejs/kit/hooks";
import { handleErrorWithSentry, sentryHandle } from "@sentry/sveltekit";
import * as Sentry from "@sentry/cloudflare";

const handleInitSentry = ({ event, resolve }) => {
  return event.platform
    ? Sentry.wrapRequestHandler(
        {
          options: {
            dsn: 'YOUR_SENTRY_DSN',
            tracesSampleRate: 1.0,
          },
          request: event.request,
          context: event.platform.ctx,
        },
        () => resolve(event)
      )
    : resolve(event);
};

export const handle = sequence(handleInitSentry, sentryHandle());

Steps to Reproduce

  1. npm create svelte@latest my-app
  2. npm i -D @sveltejs/adapter-cloudflare
  3. Follow instructions on Cloudflare Sveltekit Framework Guide

Expected Result

According to documentation I should be able to build the project without error.

Actual Result

Using @sveltejs/adapter-cloudflare
✘ [ERROR] Could not resolve "$app/stores"

node_modules/@sentry/sveltekit/build/esm/client/browserTracingIntegration.js:1:33:
  1 │ import { page, navigating } from '$app/stores';
    ╵                                  ~~~~~~~~~~~~~

You can mark the path "$app/stores" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.

error during build:

Error: Bundling with esbuild failed with 1 error
    at adapt (file:///home/onur/Documents/dev/sentry/test/node_modules/@sveltejs/adapter-cloudflare/index.js:140:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async adapt (file:///home/onur/Documents/dev/sentry/test/node_modules/@sveltejs/kit/src/core/adapt/index.js:38:2)
    at async finalise (file:///home/onur/Documents/dev/sentry/test/node_modules/@sveltejs/kit/src/exports/vite/index.js:891:7)
    at async Object.handler (file:///home/onur/Documents/dev/sentry/test/node_modules/@sveltejs/kit/src/exports/vite/index.js:921:5)
    at async PluginDriver.hookParallel (file:///home/onur/Documents/dev/sentry/test/node_modules/rollup/dist/es/shared/node-entry.js:20652:17)
    at async Object.close (file:///home/onur/Documents/dev/sentry/test/node_modules/rollup/dist/es/shared/node-entry.js:21627:13)
    at async build (file:///home/onur/Documents/dev/sentry/test/node_modules/vite/dist/node/chunks/dep-Cyk9bIUq.js:65455:17)
    at async CAC.<anonymous> (file:///home/onur/Documents/dev/sentry/test/node_modules/vite/dist/node/cli.js:828:5)

Metadata

Metadata

Assignees

Labels

Package: cloudflareIssues related to the Sentry Cloudflare Workers SDK

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions