Skip to content

Sveltekit build with adapter-cloudflare fails #9176

Closed as not planned
Closed as not planned
@MarArMar

Description

@MarArMar

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

"@sentry/sveltekit": "^7.73.0",

Framework Version

"@sentry/sveltekit": "^7.73.0",

Link to Sentry event

No response

SDK Setup

  Sentry.init({
    dsn: SENTRY_DSN,
    environment: sentryEnvironment(),
    // We recommend adjusting this value in production, or using tracesSampler
    // for finer control
    tracesSampleRate: 1.0,

    // Enables bypassing browsers adblockers
    // CF https://docs.sentry.io/platforms/javascript/guides/sveltekit/troubleshooting/?utm_expid=.OVGA2WEyTlS_pX-EST8OfQ.0#using-the-tunnel-option
    tunnel: '/api/sentry-tunnel',
  })

Steps to Reproduce

  1. Create a sveltekit project with latest Sentry
    "@sveltejs/adapter-auto": "^2.1.0",
    "@sveltejs/adapter-cloudflare": "^2.3.0",
    "@sveltejs/kit": "^1.25.1",
    "vite": "^4.4.9",
    "svelte": "^4.2.1",

  2. Install sentry

  3. Build with normal adapter-auto : works

  4. Use adapter-cloudflare

  5. Build : it fails with an error located in the sentry code

Expected Result

Build does not fail

Actual Result

vite build

[vite] Sentry plugin setup done

vite v4.4.9 building SSR bundle for production...
transforming...
"default" is imported from external module "svelte-autosize" but never used in "src/lib/components/ui/textarea/Textarea.svelte".
✓ 6107 modules transformed.
rendering chunks...

vite v4.4.9 building for production...
transforming...
✓ 6574 modules transformed.
rendering chunks...
computing gzip size...
.svelte-kit/output/client/_app/version.json 0.03 kB │ gzip: 0.05 kB
.svelte-kit/output/client/vite-manifest.json 21.25 kB │ gzip: 2.06 kB

...

.svelte-kit/output/client/_app/immutable/entry/app.27b0d20b.js 125.59 kB │ gzip: 37.30 kB
✓ built in 50.37s
.svelte-kit/output/server/vite-manifest.json 13.42 kB

...

.svelte-kit/output/server/index.js 110.56 kB

Run npm run preview to preview your production build locally.

Using @sveltejs/adapter-cloudflare
GET:/[fallback] took 7ms
X [ERROR] Could not resolve "$app/stores"

../../node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@sentry/sveltekit/esm/client/router.js:3:33:
  3 │ 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.

error during build:
Error: Build failed with 1 error:
../../node_modules/.pnpm/@sentry+sveltekit@7.69.0_@sveltejs[email protected][email protected]/node_modules/@sentry/sveltekit/esm/client/router.js:3:33: ERROR: Could not resolve "$app/stores"
at failureErrorWithLog (C:...\Turbo\node_modules.pnpm\[email protected]\node_modules\esbuild\lib\main.js:1636:15)
at C:...\Turbo\node_modules.pnpm\[email protected]\node_modules\esbuild\lib\main.js:1048:25
at C:...\Turbo\node_modules.pnpm\[email protected]\node_modules\esbuild\lib\main.js:993:52
at buildResponseToResult (C:...\Turbo\node_modules.pnpm\[email protected]\node_modules\esbuild\lib\main.js:1046:7)
at C:...\Turbo\node_modules.pnpm\[email protected]\node_modules\esbuild\lib\main.js:1075:16
at responseCallbacks. (C:...\Turbo\node_modules.pnpm\[email protected]\node_modules\esbuild\lib\main.js:697:9)
at handleIncomingPacket (C:...\Turbo\node_modules.pnpm\[email protected]\node_modules\esbuild\lib\main.js:752:9)
at Socket.readFromStdout (C:...\Turbo\node_modules.pnpm\[email protected]\node_modules\esbuild\lib\main.js:673:7)
at Socket.emit (node:events:514:28)
at Socket.emit (node:domain:489:12)
 ELIFECYCLE  Command failed with exit code 1.
ERROR: command finished with error: command (C:...\Turbo\apps\SvelteKitProject) pnpm run build exited (1)
SvelteKitProject#build: command (C:...\Turbo\apps\SvelteKitProject) pnpm run build exited (1)

Tasks: 1 successful, 2 total
Cached: 0 cached, 2 total
Time: 1m31.191s
Failed: SvelteKitProject#build

ERROR run failed: command exited (1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: sveltekitIssues related to the Sentry SvelteKit SDK

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions