Skip to content

Memory leak in deno #722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sveisvei opened this issue Apr 2, 2025 · 2 comments
Open

Memory leak in deno #722

sveisvei opened this issue Apr 2, 2025 · 2 comments
Assignees
Labels

Comments

@sveisvei
Copy link
Collaborator

sveisvei commented Apr 2, 2025

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

Image Image

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

@sveisvei
Copy link
Collaborator Author

sveisvei commented Apr 3, 2025

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:

  1. Change package.json type: commonjs (really optional)
  2. 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);

  1. run with npm run build && deno run -A --inspect ./deno.cjs

@FredrikOseberg FredrikOseberg moved this from New to Investigating in Issues and PRs Apr 9, 2025
@FredrikOseberg FredrikOseberg self-assigned this Apr 9, 2025
@LeonBroeckersAA
Copy link

We're also seeing a memory leak when using Unleash server-side in a Svelte application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Investigating
Development

No branches or pull requests

3 participants