Description
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
(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