FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(sveltekit): Detect SvelteKit server build via Vite Environment API by chargome · Pull Request #21629 · getsentry/sentry-javascript · GitHub

Repository navigation

fix(sveltekit): Detect SvelteKit server build via Vite Environment API - #21629

Merged
chargome merged 4 commits into
developfrom
cg/kit-3-env-detection
Jul 16, 2026
Merged

chargome merged 4 commits into
developfrom
cg/kit-3-env-detection

Conversation

chargome commented Jun 18, 2026 •
edited
Loading

Copy link
Copy Markdown
Member

Gets the environment using this.environment.name and falls back to config.build.ssr for older Vite versions.

Un-skips the last remaining server-side error test in the Kit 3 e2e app.

ref #21502

chargome self-assigned this Jun 18, 2026

github-actions Bot commented Jun 18, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.74 kB - -
@sentry/browser - with treeshaking flags 26.18 kB - -
@sentry/browser (incl. Tracing) 46.56 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.36 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.33 kB - -
@sentry/browser (incl. Tracing, Replay) 85.82 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.45 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.54 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 103.18 kB - -
@sentry/browser (incl. Feedback) 44.92 kB - -
@sentry/browser (incl. sendFeedback) 32.53 kB - -
@sentry/browser (incl. FeedbackAsync) 37.67 kB - -
@sentry/browser (incl. Metrics) 28.84 kB - -
@sentry/browser (incl. Logs) 29.06 kB - -
@sentry/browser (incl. Metrics & Logs) 29.75 kB - -
@sentry/react 29.54 kB - -
@sentry/react (incl. Tracing) 48.82 kB - -
@sentry/vue 33.17 kB - -
@sentry/vue (incl. Tracing) 48.54 kB - -
@sentry/svelte 27.76 kB - -
CDN Bundle 30.14 kB - -
CDN Bundle (incl. Tracing) 48.51 kB - -
CDN Bundle (incl. Logs, Metrics) 31.71 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.83 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.96 kB - -
CDN Bundle (incl. Tracing, Replay) 86.03 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.32 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.81 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 93.09 kB - -
CDN Bundle - uncompressed 89.81 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.62 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.52 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.6 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.25 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.83 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.79 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.53 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 283.48 kB - -
@sentry/nextjs (client) 51.37 kB - -
@sentry/sveltekit (client) 46.99 kB - -
@sentry/core/server 78.62 kB - -
@sentry/core/browser 64.98 kB - -
@sentry/node-core 63.2 kB - -
@sentry/node 125.43 kB +0.01% +1 B 🔺
@sentry/node (incl. diagnostics channel injection) 140.68 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 70.03 kB -0.01% -2 B 🔽
@sentry/node/light 51.32 kB +0.01% +1 B 🔺
@sentry/node - without tracing 74.69 kB - -
@sentry/aws-serverless 83.91 kB - -
@sentry/cloudflare (withSentry) - minified 182.06 kB - -
@sentry/cloudflare (withSentry) 450.81 kB - -

View base workflow run

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you apply the label PR: no-auto-close I will leave it alone ... forever!

chargome force-pushed the cg/kit-3-vite-detection branch from 06ac632 to 30c37ee Compare July 15, 2026 10:38
chargome force-pushed the cg/kit-3-env-detection branch from 95c6732 to af132f5 Compare July 15, 2026 10:38

Copy link
Copy Markdown
Member Author

bugbot run

cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit af132f5. Configure here.

chargome marked this pull request as ready for review July 15, 2026 12:31
chargome requested a review from a team as a code owner July 15, 2026 12:31
chargome requested review from mydea, nicohrubec and s1gr1d and removed request for a team July 15, 2026 12:31
chargome and others added 3 commits July 15, 2026 16:42
…nfig

SvelteKit 3.0.0-next.8 promoted the native server-tracing config out of
`experimental` (`kit.experimental.tracing.server` -> `kit.tracing.server`).
Read both locations when detecting native tracing so the SDK works across the
supported peer range (SvelteKit 2.31+ and early Kit 3 prereleases keep it under
`experimental`). Applies to detection from both the Vite plugin `api.options`
and `svelte.config.js`, and covers both shapes in the unit tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chargome force-pushed the cg/kit-3-vite-detection branch from 30c37ee to a2b8566 Compare July 15, 2026 14:57
chargome force-pushed the cg/kit-3-env-detection branch from af132f5 to 7e22244 Compare July 15, 2026 14:57
// Prefer the environment of the current build (`this.environment.name === 'ssr'`) and fall back to
// `isServerBuild` for older Vite versions that don't expose environments.
const environmentName = (this as { environment?: { name?: string } }).environment?.name;
const isServerEnvironment = environmentName != null ? environmentName === 'ssr' : !!isServerBuild;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Bug: The code hardcodes the server environment name as 'ssr'. This will fail for users who customize the environment name in Vite, leading to incorrect server-side instrumentation.
Severity: LOW

Suggested Fix

Avoid hardcoding the environment name 'ssr'. Instead, determine if the environment is server-side by a more robust method. For example, a more flexible check could be to consider any environment that is not explicitly the 'client' environment as a server-side one, which would accommodate custom names.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/sveltekit/src/vite/autoInstrument.ts#L82

Potential issue: The logic at `autoInstrument.ts` assumes the Vite server environment is
always named `'ssr'`. However, Vite's Environment API allows users to customize this
name (e.g., to `'server'`). If a custom name is used and `onlyInstrumentClient` is
`true`, the `isServerEnvironment` check will incorrectly evaluate to `false`. This
causes server-side universal load functions to be instrumented when they should be
skipped, resulting in incorrect stack frames for server-side errors in production for
users with this specific configuration.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is set by SvelteKit, right?

// Prefer the environment of the current build (`this.environment.name === 'ssr'`) and fall back to
// `isServerBuild` for older Vite versions that don't expose environments.
const environmentName = (this as { environment?: { name?: string } }).environment?.name;
const isServerEnvironment = environmentName != null ? environmentName === 'ssr' : !!isServerBuild;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is set by SvelteKit, right?

Base automatically changed from cg/kit-3-vite-detection to develop July 16, 2026 08:38
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chargome merged commit 0c87729 into develop Jul 16, 2026
311 checks passed
chargome deleted the cg/kit-3-env-detection branch July 16, 2026 11:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL