Skip to content

feat(core,cloudflare): Add dispose method to CloudflareClient for proper cleanup#19364

Draft
JPeer264 wants to merge 3 commits intodevelopfrom
jp/dispose-client
Draft

feat(core,cloudflare): Add dispose method to CloudflareClient for proper cleanup#19364
JPeer264 wants to merge 3 commits intodevelopfrom
jp/dispose-client

Conversation

@JPeer264
Copy link
Member

similar to #19336 - this PR is here to reduce the memory footprint and memory leaks for Cloudflare.

This adds two things:

MemoryProfiler

A way to measure the heap profile in Playwright (kudos to @aishahsofea for this idea as written up here) - we could create a separate PR for it if you want, but it won't be used anywhere that is why I left it in this PR

Dispose Client

A way to dispose the client entirely. Every request in Cloudflare Workers create their own client. However, the client stays in-memory and the isolate might not be evicted correctly. As of now the memory footprint got reduced from ~1mb to ~730kb after 50 requests. The goal is to reduce the memory footprint even further - the test currently makes sure that future code won't increase memory for Cloudflare by accident (that is where the MemoryProfiler comes in handy).

The dispose() method got added on purpose into the core client, as this might come in handy for future integrations like the @sentry/hono SDK

@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2026

Codecov Results 📊


Generated by Codecov Action

@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 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.56 kB - -
@sentry/browser - with treeshaking flags 24.08 kB - -
@sentry/browser (incl. Tracing) 42.36 kB - -
@sentry/browser (incl. Tracing, Profiling) 47.03 kB - -
@sentry/browser (incl. Tracing, Replay) 81.18 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.8 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 85.87 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 98.03 kB - -
@sentry/browser (incl. Feedback) 42.29 kB - -
@sentry/browser (incl. sendFeedback) 30.23 kB - -
@sentry/browser (incl. FeedbackAsync) 35.22 kB - -
@sentry/browser (incl. Metrics) 26.74 kB - -
@sentry/browser (incl. Logs) 26.88 kB - -
@sentry/browser (incl. Metrics & Logs) 27.56 kB - -
@sentry/react 27.33 kB - -
@sentry/react (incl. Tracing) 44.72 kB - -
@sentry/vue 30.01 kB - -
@sentry/vue (incl. Tracing) 44.22 kB - -
@sentry/svelte 25.58 kB - -
CDN Bundle 28.11 kB - -
CDN Bundle (incl. Tracing) 43.2 kB - -
CDN Bundle (incl. Logs, Metrics) 28.95 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 44.03 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 68.02 kB - -
CDN Bundle (incl. Tracing, Replay) 80.07 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 80.94 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 85.5 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.4 kB - -
CDN Bundle - uncompressed 82.22 kB - -
CDN Bundle (incl. Tracing) - uncompressed 127.93 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 85.05 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 130.76 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 208.71 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 244.81 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 247.63 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 257.61 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 260.42 kB - -
@sentry/nextjs (client) 47.07 kB - -
@sentry/sveltekit (client) 42.81 kB - -
@sentry/node-core 52.21 kB +0.13% +67 B 🔺
@sentry/node 166.59 kB +0.14% +231 B 🔺
@sentry/node - without tracing 94.01 kB +0.08% +69 B 🔺
@sentry/aws-serverless 109.51 kB +0.07% +66 B 🔺

View base workflow run

@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
⚠️ 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.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 9,075 - 9,721 -7%
GET With Sentry 1,705 19% 1,710 -0%
GET With Sentry (error only) 6,100 67% 6,302 -3%
POST Baseline 1,202 - 1,216 -1%
POST With Sentry 595 50% 603 -1%
POST With Sentry (error only) 1,070 89% 1,078 -1%
MYSQL Baseline 3,273 - 3,323 -2%
MYSQL With Sentry 490 15% 518 -5%
MYSQL With Sentry (error only) 2,669 82% 2,777 -4%

View base workflow run

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