supabase-js icon indicating copy to clipboard operation
supabase-js copied to clipboard

Long running realtime channel results in steady growing memory

Open ssadel opened this issue 1 year ago • 3 comments

Bug report

  • [ ] I confirm this is a bug with Supabase, not with my own application.
  • [x] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

I'm experimenting with a single long running realtime channel (postgres changes) in my deployed node.js server for my use case of sending SSE to various clients given updates.

After implementing and deploying, I noticed a steady increase in memory over time in my dash. So I removed all other new code except the Supabase realtime connection and redeployed and the result was the same. It seems there could possibly be a memory leak using a long running realtime connection using the js lib.

Let me know if I can provide any other info - I'm new to backend dev so bear with me lol - but have experience debugging mem leaks on front end clients

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

I'm honestly not sure how to test this without actually doing it - I'm sure there's a way but I'm not super experienced with node.js dev. But in a prod Heroku environment, simply creating an instance of this func on launch of the server

export function listenForTaskCompletion(callback: (taskData: unknown) => void): RealtimeChannel {
    return client
        .channel("tasks")
        .on("postgres_changes", { event: "UPDATE", schema: "public" }, (payload) => {
            callback(payload.new);
        })
        .subscribe();
}

export function initSSE() {
    listenToSubabaseTaskCompletion();
}

function listenToSubabaseTaskCompletion() {
    listenForTaskCompletion((taskData) => {
        console.log("HERE: ", taskData);
    });
}

initSSE();

Then waiting over time, observing my dash, memory slowly grows over time

Screenshot 2024-06-05 at 10 45 01 AM (the down spike being a re-deployment, and towards the end it's less noticable, increasing <1mb / hr)

Without the realtime instance, the memory is consistent, and spikes return to baseline

Expected behavior

Spikes in memory are expected, but some sort of baseline I think should be occurring if there are no mem leaks

Screenshots

Attached above

System information

  • OS: macOS
  • Browser (if applies) n/a
  • Version of supabase-js: ^2.43.1
  • Version of Node.js: 20.14.0

Additional context

Node.js TS express app deployed on Heroku

ssadel avatar Jun 05 '24 14:06 ssadel

This issue has been automatically marked as stale because it has not had any activity for 1 year. It will be closed in 6 months if no further activity occurs. If this issue is still relevant, please comment to keep it open.

github-actions[bot] avatar Oct 19 '25 00:10 github-actions[bot]

@ssadel can you please check if latest version (which contains this commit) fixes your issue?

Latest version is v2.81.0.

mandarini avatar Nov 10 '25 15:11 mandarini

This issue has been marked as stale. Please confirm if the issue still occurs with the latest SDK version.

It will be closed in 30 days if no update is provided.

github-actions[bot] avatar Jan 11 '26 00:01 github-actions[bot]