Skip to content
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

Long running realtime channel results in steady growing memory #1204

Open
1 of 2 tasks
ssadel opened this issue Jun 5, 2024 · 0 comments
Open
1 of 2 tasks

Long running realtime channel results in steady growing memory #1204

ssadel opened this issue Jun 5, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ssadel
Copy link

ssadel commented Jun 5, 2024

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • 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 ssadel added the bug Something isn't working label Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant