realtime-csharp icon indicating copy to clipboard operation
realtime-csharp copied to clipboard

Realtime Events not respecting options

Open Kuffs2205 opened this issue 2 years ago • 11 comments

In my options, I am listening only for Updates.

        TestChannel = client.Realtime.Channel($"MyChannel-{parentID}")
        TestChannel.Register(New PostgresChangesOptions("public",
                                                        "TestData",
                                                        PostgresChangesOptions.ListenType.Updates,
                                                        $"parent=eq.{parentID}"))

        Await TestChannel.Subscribe

However, I am also receiving Inserts and Deletes.

Also, the Delete messages received do not correlate to my filter. Every single client gets every single delete even when the delete is for a different parentID.

Reproduction Steps

Click "Insert Subscribed Row" - The Insert event is fired Incorrect as I'm listening only for updates Click "Insert Random Row" - No event fired Correct

In Supabase studio.

Edit one of the random rows (X=1,Y=1) No event fired Correct Edit one of the subscribed rows (X=99,Y=99) Update Event fired Correct Delete one of the subscribed rows Delete Event Fired Incorrect as I'm not listening for deletes Delete one of the random rows Delete Event Fired Incorrect as I'm not listening for deletes AND I'm not subscribed to those records

https://github.com/Kuffs2205/TestRealtime.git

I'm up to 10,000,000 messages this month. I queried this as it seemed excessive. Now I see the Delete issue, it makes sense.

I wasn't sure if I should post the url and key publicly so I didn't but I can give it you if you want it.

Kuffs2205 avatar Apr 25 '23 10:04 Kuffs2205

Thanks for the report @Kuffs2205 - As this library is modeled off of realtime-js, went there to attempt to reproduce. I was able to reproduce the same issue on @supabase/[email protected] with the delete filter not being respected. We'll see what they have to say!

acupofjose avatar Apr 25 '23 12:04 acupofjose

Thanks for taking a look. I'm never quite sure if it's just me with a poor understanding or not.

Kuffs2205 avatar Apr 25 '23 13:04 Kuffs2205

Looks like this is a limitation known by the team at realtime - filters on delete events are currently unsupported. I'm going to keep this open to track it! (See the referenced issue)

acupofjose avatar Apr 26 '23 00:04 acupofjose

So filters do not work at all then as PostgresChangesOptions.ListenType.Updates still gives me Inserts and Deletes too.

This is not sustainable. Literally millions of messages being sent and charged that I do not want and my user base is not yet that big. Hope they sort it soon or at least document it better so people don't fall into the trap of paying for unwanted messages.

Kuffs2205 avatar Apr 26 '23 06:04 Kuffs2205

@Kuffs2205 unfortunately I'm just a volunteer library maintainer - but I absolutely agree with you. Maybe consider reaching out to supabase support about considering your account status and being charged for extra, unwanted events?

acupofjose avatar Apr 27 '23 13:04 acupofjose

I wasn't suggesting you were at fault at all. Sorry if it seemed so.

Kuffs2205 avatar Apr 27 '23 13:04 Kuffs2205

No worries - just wanted to offer a course of action in the meantime!

acupofjose avatar Apr 27 '23 13:04 acupofjose

Can I just clarify something as it seems that all the focus was the "eq" filter not working for deletes but there was another issue in that:

PostgresChangesOptions.ListenType.Updates PostgresChangesOptions.ListenType.Inserts

was also not being respected and all events were being returned regardless of what was asked for

Is this related or a separate issue?

Kuffs2205 avatar Apr 27 '23 13:04 Kuffs2205

🤦 I got caught up in the filter thing that I forgot to check the second part of your issue! Let me get back to you on that.

acupofjose avatar Apr 27 '23 14:04 acupofjose

Okay, so I can confirm that there is a bug in the library's code. It is sending a request to subscribe to all events instead of respecting the options - so good catch there - I'll issue a quick fix for that - Thank you!!

However, I can also duplicate the same issue on the javascript library, where a postgres_changes listener is started with the expectation of only receiving UPDATE events, but the socket sends INSERT and DELETE events as well.

SO! You are correct. The library is not respecting the options (fix coming momentarily). But the websocket server sends events regardless (upstream issue that I also need to make another issue for)!

acupofjose avatar Apr 28 '23 02:04 acupofjose

Thanks for checking that out. I really appreciate your efforts on this library. I wouldn't be using Supabase without it.

Kuffs2205 avatar Apr 28 '23 10:04 Kuffs2205