Skip to content

Sveltekit build with adapter-cloudflare fails #9176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
MarArMar opened this issue Oct 4, 2023 · 5 comments
Closed
3 tasks done

Sveltekit build with adapter-cloudflare fails #9176

MarArMar opened this issue Oct 4, 2023 · 5 comments
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK

Comments

@MarArMar
Copy link

MarArMar commented Oct 4, 2023

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)

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Oct 4, 2023
@github-actions github-actions bot added the Package: sveltekit Issues related to the Sentry SvelteKit SDK label Oct 4, 2023
@MarArMar
Copy link
Author

MarArMar commented Oct 4, 2023

Replacing again the adapter-cloudflare

with adapter-auto : build works again

But I am deploying on cloudflare so this blocks all use of Sentry for me.

@MarArMar
Copy link
Author

MarArMar commented Oct 4, 2023

I removed sentry, ran the build again with adapter-cloudflare, it works again

Totally looks like it s an incompatibility of sentry with the adapter-cloudflare

Completely blocks integration of Sentry into production

@Lms24
Copy link
Member

Lms24 commented Oct 5, 2023

Hi @MarArMar thanks for writing in!

As of our documentation, we currently do not guarantee support for the cloudflare adapter. This is especially due to the cloudflare workers runtime not being Node-API compatible. It's a similar story to Vercel's Edge runtime (tracking in #9107) which we're likely going to tackle before supporting other runtimes. The good news though is that we already created the necessary basis - a runtime-agnostic server client for the SDK (#8693).

I'm going to close this issue because it's a duplicate of #8291 and we're already aware of it. Please lmk if you think this needs reopening. Otherwise, feel free to comment in #8921. Thanks! :)

@Lms24 Lms24 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2023
@getsantry getsantry bot removed the status in GitHub Issues with 👀 Oct 5, 2023
@MarArMar
Copy link
Author

MarArMar commented Oct 5, 2023

😥

@jerriclynsjohn
Copy link

Looks like #8693 is closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK
Projects
Archived in project
Development

No branches or pull requests

3 participants