Skip to content

ref(sveltekit): Wrap load functions in place with the rewriter core - #26103

Draft
timfish wants to merge 3 commits into
ref/cloudflare-call-site-rewriterfrom
ref/sveltekit-call-site-rewriter
Draft

timfish wants to merge 3 commits into
ref/cloudflare-call-site-rewriterfrom
ref/sveltekit-call-site-rewriter

Conversation

@timfish

@timfish timfish commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Why: The load hook served a proxy module that re-exported each route file under a ?sentry-auto-wrap query. That doubled the module count per route, put the query into stack frames and source maps (which needed extra code in rewriteFramesIntegration and the source map clean-up to remove it), and could not wrap export { load } from './shared'. The transform now wraps the load export in the route file itself and skips loads the user wrapped by hand. It reads the code Vite passes in instead of reading the file from disk a second time, so acorn and @sveltejs/acorn-typescript are no longer dependencies.

How to review: Start with src/vite/autoInstrument.ts. The other source changes remove the query handling.

Unsure about: At build time, a load that ends in satisfies PageLoad doesn't count as already wrapped. The runtime guard still stops a double wrap.

Ref #25776

@timfish
timfish added this pull request to stack #26105 November 4, 2026 13:58
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: e4a4cad (PR test merge using develop at 5b9805f)

Against: 13dcbf8 (develop) · base run #67598

⚠️ Baseline mismatch: 5 develop commit(s) in the PR build are missing from the baseline. Their size changes also affect this comparison. Compare commits. Re-run once develop's baseline build for 5b9805f finishes.

Path Size % Change Change
@sentry/browser 30.34 kB - -
@sentry/browser - with treeshaking flags 28.52 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.4 kB - -
@sentry/browser (incl. Tracing) 52.97 kB - -
@sentry/browser (incl. Tracing Core) 40.39 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.97 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.83 kB - -
@sentry/browser (incl. Tracing, Replay) 93.02 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.86 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.36 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.96 kB - -
@sentry/browser (incl. Feedback) 48.31 kB - -
@sentry/browser (incl. sendFeedback) 30.91 kB - -
@sentry/browser (incl. FeedbackAsync) 35.96 kB - -
@sentry/browser (incl. Metrics) 31.66 kB - -
@sentry/browser (incl. Logs) 31.94 kB - -
@sentry/browser (incl. Metrics & Logs) 32.59 kB - -
@sentry/react 32.36 kB - -
@sentry/react (incl. Tracing) 55.57 kB - -
@sentry/vue 38.53 kB - -
@sentry/vue (incl. Tracing) 55.91 kB - -
@sentry/svelte 30.36 kB - -
@sentry/effect (client) 42.02 kB - -
@sentry/effect (client, incl. Tracing) 49.17 kB - -
@sentry/effect (client, incl. Tracing, Logs, Metrics) 59.08 kB - -
@sentry/remix (Remix 3 client bundle) 58.61 kB - -
CDN Bundle 32.25 kB - -
CDN Bundle (incl. Tracing) 53.37 kB - -
CDN Bundle (incl. Logs, Metrics) 35.04 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.91 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 76.11 kB - -
CDN Bundle (incl. Tracing, Replay) 91.26 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.88 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.69 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.24 kB - -
CDN Bundle - uncompressed 94.2 kB - -
CDN Bundle (incl. Tracing) - uncompressed 157.8 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 102.54 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 165.43 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 232.78 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 278.07 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 285.7 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 290 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 297.62 kB - -
@sentry/nextjs (client) 59.34 kB - -
@sentry/sveltekit (client) 54.25 kB - -
@sentry/core/server 45.81 kB - -
@sentry/core/browser 14.41 kB - -
@sentry/node 156.02 kB -0.01% -2 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.46 kB - -
@sentry/node - without tracing 89.04 kB -0.01% -5 B 🔽
@sentry/node - without channel injection 144.95 kB -0.01% -2 B 🔽
@sentry/aws-serverless 99.72 kB -0.01% -7 B 🔽
@sentry/cloudflare (withSentry) - minified 209.4 kB - -
@sentry/cloudflare (withSentry) 486.21 kB - -
@sentry/cloudflare (withSentry, instrumented CommonJS package) - minified 212.34 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 234.63 kB - -

View base workflow run

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 3 not successful, 62 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E cloudflare-workers-without-tracing-send-to-sentry Test (optional) Failing after 49s Details
❌ CI: Optional E2E Tests / E2E nuxt-5 (development) Test (optional) Failing after 38s Details
❌ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Failing after 4m Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E cloudflare-mastra Test (optional) Successful in 54s Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (kv-cache) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E astro-7 (static trace lifecycle) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) Successful in 53s Details
✅ CI: Optional E2E Tests / E2E node-eve (0.x) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E express-5 (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 40s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) Successful in 38s Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 46s Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 42s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel Test (optional) Successful in 44s Details
✅ CI: Optional E2E Tests / E2E react-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think Test (optional) Successful in 55s Details
✅ CI: Optional E2E Tests / E2E express-5 (bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E solid-2-ssr (cloudflare) Test (optional) Successful in 29s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 59s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 41s Details
✅ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 39s Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (bun) Test (optional) Successful in 57s Details
✅ CI: Optional E2E Tests / E2E solidstart-2-tunnel Test (optional) Successful in 46s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel (cloudflare) Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (cloudflare) Test (optional) Successful in 43s Details
✅ CI: Optional E2E Tests / E2E express-5 (deno) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (latest) Test (optional) Successful in 58s Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (deno) Test (optional) Successful in 55s Details
✅ CI: Optional E2E Tests / E2E nextjs-14-supabase Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 4m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 32s Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 52s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-eve Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 40s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-cloudflare Test (optional) Successful in 31s Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 23s Details
✅ CI: Optional E2E Tests / E2E node-flue Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 48s Details
✅ CI: Optional E2E Tests / E2E node-pi-durable Test (optional) Successful in 34s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry (static trace lifecycle) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 (MCP SDK OpenTelemetry) Test (optional) Successful in 41s Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 28s Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E node-mastra Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E node-eve (content off) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 54s Details

@timfish
timfish force-pushed the ref/sveltekit-call-site-rewriter branch from 48f0c25 to 9aafb1f Compare November 4, 2026 14:23
The `load` hook served a proxy module that re-exported the route file under a `?sentry-auto-wrap` query. That doubled the module count per route, leaked the query into stack frames and source maps, and could not wrap `export { load } from './shared'`.

The transform now wraps the `load` export in the route file itself, so the query and the code that stripped it again are gone. It reads the code Vite hands over instead of a second copy from disk, so acorn is no longer needed.
The proxy module renamed the route `load` to `load$1` in the bundle. In-place wrapping keeps the name.
… app

Load functions are wrapped in the route file itself, so no module carries the `?sentry-auto-wrap` query.
@timfish
timfish force-pushed the ref/sveltekit-call-site-rewriter branch from 9aafb1f to 1f3c7db Compare November 23, 2026 15:27

This branch has not been deployed

No deployments
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.

1 participant