Skip to content

fix(sveltekit): Handle server-only and shared load functions #7581

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

Merged
merged 3 commits into from
Mar 23, 2023

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Mar 23, 2023

Previously, our server wrapLoadWithSentry assumed that load in +page.ts and +page.server.ts work identically. Unfortunately, the load event arg has different contents for both, namely that the server-only load event contains a request object while the shared (client and server) load event doesn't. This PR fixes that by distinguishing between the two load types within the wrapper. Users can still use the same wrapper for both cases.

Furthermore, this PR removes the usage of domains in the load wrapper, as on the server-side, we're already in a domain when handleSentry is used. Creating another domain here, caused the creation of a new transaction instead of adding the span to the transaction that was created by handleSentry.

ref #7403

@Lms24 Lms24 requested a review from AbhiPrasad March 23, 2023 08:16
if (isServerOnlyLoad(event)) {
const sentryTraceHeader = event.request.headers.get('sentry-trace');
const baggageHeader = event.request.headers.get('baggage');
const traceparentData = sentryTraceHeader ? extractTraceparentData(sentryTraceHeader) : undefined;
Copy link
Member

Choose a reason for hiding this comment

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

m: This conditional branching is a little confusing to me. Can we do it like the following?

Could we extract the request.headers logic into a separate function that conditionally returns the traceparentData and dynamicSamplingContext?

We can then just reference those directly like trace function used to.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done! Also removed the domain (will update the PR description for future refrerence)

@github-actions
Copy link
Contributor

github-actions bot commented Mar 23, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.57 KB (-0.01% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 64.2 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 19.13 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified) 56.58 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 21.59 KB (0%)
@sentry/browser - Webpack (minified) 71.66 KB (0%)
@sentry/react - Webpack (gzipped + minified) 21.61 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 51.88 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 27.93 KB (-0.01% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 26.11 KB (+0.01% 🔺)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 44.33 KB (+0.01% 🔺)
@sentry/replay - Webpack (gzipped + minified) 38.39 KB (0%)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 62.54 KB (-0.01% 🔽)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 56.06 KB (0%)

@Lms24 Lms24 force-pushed the lms/sveltekit-fix-server-load branch from 4bc2407 to 62dd95d Compare March 23, 2023 14:21
@Lms24 Lms24 requested a review from AbhiPrasad March 23, 2023 14:23
@Lms24 Lms24 self-assigned this Mar 23, 2023
@Lms24 Lms24 merged commit 0a4a072 into develop Mar 23, 2023
@Lms24 Lms24 deleted the lms/sveltekit-fix-server-load branch March 23, 2023 16:01
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.

2 participants