Skip to content

SvelteKit Cloudflare adapter failing #8291

Closed
@lucasnad27

Description

@lucasnad27

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

Framework Version

@sveltejs/kit == 1.20.0

Link to Sentry event

No response

SDK Setup

hooks.client.ts...

Sentry.init({
	dsn: config.sentryDSN,
	environment: config.env,
	tracesSampleRate: 1,
	replaysSessionSampleRate: 0.1,
	replaysOnErrorSampleRate: 1,
	integrations: [new Sentry.Replay()]
});

hooks.server.ts

Sentry.init({
	dsn: config.sentryDSN,
	environment: config.env,
	tracesSampleRate: 1
});

Steps to Reproduce

  1. manually setup the sveltekit + sentry integration
  2. verify it's working locally
  3. install adapter-cloud flare and update svelte.config.ts according to sveltekit documentation -- partial example provided below.
  4. deploy to cloudflare (can't easily give you a way to reproduce this portion, but let me know if I can additional details

sample svelte.config.js

import adapter from '@sveltejs/adapter-cloudflare';
import { vitePreprocess } from '@sveltejs/kit/vite';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	// Consult https://kit.svelte.dev/docs/integrations#preprocessors
	// for more information about preprocessors
	preprocess: vitePreprocess(),
	kit: {
		adapter: adapter()
};

export default config;

Expected Result

Successful build & deploy from cloudflare pages

Actual Result

16:37:00.142 | > Using @sveltejs/adapter-cloudflare
-- | --
16:37:00.627 | ✘ [ERROR] Could not resolve "$app/stores"
16:37:00.628 |  
16:37:00.628 | node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@sentry/sveltekit/esm/client/router.js:3:33:
16:37:00.628 | 3 │ import { page, navigating } from '$app/stores';
16:37:00.628 | ╵                                  ~~~~~~~~~~~~~
16:37:00.628 |  
16:37:00.629 | You can mark the path "$app/stores" as external to exclude it from the bundle, which will remove this error.
16:37:00.629 |  
16:37:01.102 | error during build:
16:37:01.103 | Error: Build failed with 1 error:
16:37:01.104 | node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@sentry/sveltekit/esm/client/router.js:3:33: ERROR: Could not resolve "$app/stores"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: sveltekitIssues related to the Sentry SvelteKit SDK

    Type

    Projects

    Status

    No status

    Status

    No status

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions