You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(core,cloudflare): Add dispose to the client for proper cleanup (#19506)
closes#19475
closes
[JS-1785](https://linear.app/getsentry/issue/JS-1785/investigate-memory-leaks-in-cloudflare)
This is a way to dispose the client entirely. Every request in
Cloudflare Workers create their own client. Once the request is done the
client would stay in memory forever, unless we `dispose` it after every
request. We also have to wait until all `waitUntil`s are finished,
otherwise we would loose these traces.
The `dispose()` method got added on purpose into the core client, as the
`getCurrentClient()` would return a `Client`. The `dispose()` method
actually only has functionality inside the `ServerRuntimeClient`, as
only the server would need this functionality.
There is still a leak in one of the default integrations, but when
running load tests against [the reproduction
repo](https://github.com/JPeer264/temp-cloudflare-leak) and setting
`defaultIntegrations: false`, then no leak is happening.
FWIW there will be a separate PR for adding a MemoryProfiler as seen in
#19364, to prevent this memory leak in the future.
0 commit comments