Closed enyo closed 6 months ago
Hi @enyo thanks for writing in!
A couple of questions:
@Lms24 I've isolated the issue, and it's due to rendering on the edge with Vercel.
npm create svelte@latest my-app
pnpm add -D @sveltejs/adapter-vercel
@sveltejs/adapter-vercel
in svelte.config.js
src/routes/+page.js
file with this content:
export const config = {
runtime: 'edge'
};
Now building fails with the above error message.
I found the solution for this:
export const config = {
runtime: 'edge',
external: ['@sentry/sveltekit'],
};
@Lms24 maybe this could be added to the docs?
Ah... of course this doesn't work. This does the opposite of what I thought it would do, and doesn't include the package at all, so of course this will work in the build, but fail when trying to deploy.
Hi @enyo thanks for writing in! I'm fairly certain the build error originates because you're using Vercel's edge runtime. Unfortunately, at this time, our SvelteKit SDK is not compatible with Vercel's edge runtime (as stated in our docs). Edge runtime support is being tracked in https://github.com/getsentry/sentry-javascript/issues/9107. We're currently focussing all our efforts on shipping the next major version of the JS SDKs but it's likely that we'll edge support soon afterwards.
I'm going to close this issue because in essence I believe it's a duplicate of #9107. Please feel free to ping me if you think this should be reopened.
I see @Lms24 . Is there a way I can disable sentry for edge functions? I just have a few routes that use edge, and I can't use sentry at all because of this issue.
Hmm this is unfortunately a bit tricky because you somehow need to conditionally decide if the Sentry import and code in hooks.server.ts
should be present, depending on if what you're building is for the edge function or not.
This is generally one of the tricky parts to solve for edge support: When do we inject our Node SDK and when the (potential) Edge SDK. I also haven't looked much into the vercel adapter how they actually build stuff for edge vs serverless.
What you can try to do (actually, I'd be really interested in the results) is create a vite plugin that loads a dummy file instead of the actual one. But again, you need a way to find out if Sentry should be added or not. That's the challenge you (and we eventually) need to solve.
This error also happens when deploying to Cloudflare's Pages. For very likely similar reasons
The same happens for Netlify with the edge option turned on
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.101.1
Framework Version
SvelteKit 2.4.3
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
I installed sentry in my SvelteKit app as the docs suggested (with the wizard). I double checked everything with the manual installation guide
Expected Result
It working
Actual Result
Building the SvelteKit project fails: