Skip to content

ref(cloudflare): Prepare for WorkerEntrypoint#19742

Open
JPeer264 wants to merge 1 commit intodevelopfrom
jp/handler-with-sentry
Open

ref(cloudflare): Prepare for WorkerEntrypoint#19742
JPeer264 wants to merge 1 commit intodevelopfrom
jp/handler-with-sentry

Conversation

@JPeer264
Copy link
Member

(preparation for #15942)

This PR is wether adding nor removing any functionality of the Cloudflare SDK. It is basically just splitting up the handler.ts into it smaller functions. So it may look huge, but it doesn't do anything.


Main changes:

  • handler.ts -> withSentry.ts
  • Single handler instrumentations of handler.ts moved into (instrumentations/worker/instrument*.ts)
    • "core functionality" of the instrumentation (first split)
    • and a ExportedHandler specific instrumentation (second split)

E.g. following is a pseudo code of the split

const withSentry = () => {
  // first split
  if ('fetch' in handler) {
    handler.fetch = new Proxy(handler.fetch {
      const options = getFinalOptions();
      
      // second split = "core functionaltiy" of fetch
      return withIsolationScope(() => startSpan())
    })
  }
}

When implementing the WorkerEntrypoint the "core functionality" part can easily be reused, without touching any further code.

@JPeer264 JPeer264 requested review from Lms24 and logaretm March 10, 2026 16:41
@JPeer264 JPeer264 self-assigned this Mar 10, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2026

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 25.64 kB +0.05% +12 B 🔺
@sentry/browser - with treeshaking flags 24.14 kB +0.03% +7 B 🔺
@sentry/browser (incl. Tracing) 42.62 kB +0.44% +184 B 🔺
@sentry/browser (incl. Tracing, Profiling) 47.28 kB +0.4% +187 B 🔺
@sentry/browser (incl. Tracing, Replay) 81.42 kB +0.22% +171 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 71 kB +0.18% +125 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 86.12 kB +0.21% +178 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 98.37 kB +0.18% +167 B 🔺
@sentry/browser (incl. Feedback) 42.45 kB +0.03% +9 B 🔺
@sentry/browser (incl. sendFeedback) 30.31 kB +0.05% +14 B 🔺
@sentry/browser (incl. FeedbackAsync) 35.36 kB +0.04% +12 B 🔺
@sentry/browser (incl. Metrics) 26.92 kB +0.48% +126 B 🔺
@sentry/browser (incl. Logs) 27.07 kB +0.48% +128 B 🔺
@sentry/browser (incl. Metrics & Logs) 27.74 kB +0.46% +127 B 🔺
@sentry/react 27.39 kB +0.04% +9 B 🔺
@sentry/react (incl. Tracing) 44.95 kB +0.41% +180 B 🔺
@sentry/vue 30.08 kB +0.03% +7 B 🔺
@sentry/vue (incl. Tracing) 44.48 kB +0.42% +183 B 🔺
@sentry/svelte 25.66 kB +0.04% +9 B 🔺
CDN Bundle 28.27 kB +0.35% +97 B 🔺
CDN Bundle (incl. Tracing) 43.5 kB +0.55% +237 B 🔺
CDN Bundle (incl. Logs, Metrics) 29.13 kB +0.42% +121 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 44.34 kB +0.56% +243 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 68.2 kB +0.16% +107 B 🔺
CDN Bundle (incl. Tracing, Replay) 80.32 kB +0.23% +183 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 81.22 kB +0.27% +218 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 85.86 kB +0.24% +205 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.76 kB +0.27% +226 B 🔺
CDN Bundle - uncompressed 82.56 kB +0.26% +211 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 128.5 kB +0.34% +433 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 85.43 kB +0.29% +244 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 131.37 kB +0.36% +466 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 209.06 kB +0.11% +212 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 245.35 kB +0.17% +401 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 248.21 kB +0.18% +434 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 258.26 kB +0.16% +401 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 261.11 kB +0.17% +434 B 🔺
@sentry/nextjs (client) 47.37 kB +0.39% +184 B 🔺
@sentry/sveltekit (client) 43.07 kB +0.42% +178 B 🔺
@sentry/node-core 52.27 kB +0.06% +31 B 🔺
@sentry/node 174.76 kB +0.04% +54 B 🔺
@sentry/node - without tracing 97.43 kB +0.06% +50 B 🔺
@sentry/aws-serverless 113.23 kB +0.04% +45 B 🔺

View base workflow run

@JPeer264 JPeer264 force-pushed the jp/handler-with-sentry branch from d8216ba to 8887864 Compare March 11, 2026 09:56
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