feat(core,cloudflare): Add dispose method to CloudflareClient for proper cleanup#19364
Draft
feat(core,cloudflare): Add dispose method to CloudflareClient for proper cleanup#19364
Conversation
Contributor
Codecov Results 📊Generated by Codecov Action |
Contributor
size-limit report 📦
|
Contributor
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.
|
…ent for proper cleanup
8ba7238 to
d43b738
Compare
…lareClient for proper cleanup
… CloudflareClient for proper cleanup
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
MemoryProfilercomes 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/honoSDK