Memory leak in deno
Describe the bug
Hello, We have been running unleash-client-node in Deno for quite a while, and are seeing a steady memory leak for each fetch/poll request. If I increase the polling to each second, it grows and is reproducible in a short time.
Steps to reproduce the bug
1.set up a long running process 2. initiate unleash 3. wait, and see memory increase
Expected behavior
Looks for me to be some retention of objects via make-fetch-happen, its not freed.
Logs, error output, etc.
Screenshots
Additional context
I can work on a fix, but would like to discuss a bit first. Should this project even target deno?
Unleash version
No response
Subscription type
Open source
Hosting type
Self-hosted
SDK information (language and version)
No response
I have confirmed the culprit is the use of make-fetch-happen. Using fetch instead, has no memory leak in deno.
I tried updating the version to latest, but problem persists.
Reproduction in this repo:
- Change package.json
type: commonjs(really optional) - create deno.cjs
const unleash = require('./lib/index.js');
const client = unleash.initialize({
url: 'https://eu.app.unleash-hosted.com/demo/api/',
appName: 'my-app',
instanceId: 'my-instance',
refreshInterval: 1 * 1000,
customHeaders: {
Authorization: 'altsaad:development.397feb4b819e14c623536493b1cf1e0f38faee9e2a9ea16659070ff7',
},
});
client.on('synchronized', () => {
console.log('Unleash client synchronized');
});
client.on('error', (error) => {
console.error('Unleash client error:', error);
});
client.on('ready', () => {
console.log('Unleash client ready');
});
client.on('update', (data) => {
console.log('Unleash client update:', data);
});
client.on('registered', (data) => {
console.log('Unleash client registered:', data);
});
client.on('clientReady', () => {
console.log('Unleash client ready');
});
console.log('Unleash client initialized:', client.isSynchronized());
setInterval(() => {
console.log('Unleash client status:', client.isSynchronized(), client.isEnabled('my-feature'));
}, 10_000);
- run with
npm run build && deno run -A --inspect ./deno.cjs
We're also seeing a memory leak when using Unleash server-side in a Svelte application.
Is this Deno specific? We are not running Deno but are Node v22 and experiencing the same issue.