Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Realtime subscription takes few seconds to recognize changes after successful subscription

Aperta
#322 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
csharp

Direzione di ricerca

Inizia dal flusso del canale Realtime usando Channel, Subscribe(), PostgresChangesOptions e AddPostgresChangeHandler nella riproduzione. Confronta la conferma corretta della sottoscrizione con il momento in cui le modifiche al database iniziano a raggiungere l'handler, usando la configurazione Unity/IL2CPP descritta. Il lavoro è completato quando una tabella sottoscritta riceve le modifiche senza il gap di diversi secondi segnalato, con copertura di regressione se viene trovata una posizione di test esistente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: realtime bug

Description

After successfully subscribing to a Realtime channel with channel.Subscribe(), there is approximately a 4-second delay before the subscription actually starts recognizing changes to the subscribed table. This occurs even though the subscription appears to be successful immediately (indicated by successful subscription log messages).

Environment

  • Unity Version: 2022.3.35f1
  • Supabase.Realtime Version: 6.0.4
  • Operating System: Windows
  • Project Type: Unity C# (IL2CPP)

Reproduction Steps

  1. Initialize Supabase Realtime client and ensure socket connection
  2. Subscribe to a table using the following pattern:
//Method-Setup
 public async Task<string> SubscribeToTable(string tableName, string filter, string columnName, bool isCustomer, Action<string> onValueChanged)
 {
     try
     {
         var channel = client.Realtime.Channel($"public:{tableName}");        

         var subscriptionInfo = new SubscriptionInfo
         {
             TableName = tableName,
             ColumnName = columnName,
             Filter = filter,
             Channel = channel
         };

         subscriptionInfo.OnValueChanged += onValueChanged;

         try
         {
             channel.Register(new PostgresChangesOptions(
                 schema: "public",
                 table: tableName,
                 eventType: PostgresChangesOptions.ListenType.All,
                 filter: filter
             ));

             channel.AddPostgresChangeHandler (PostgresChangesOptions.ListenType.All, (sender, response) =>
             {
                 try
                 {
                     if (response?.Payload?.Data?.Record != null)
                     {
                         var recordDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(
                             JsonConvert.SerializeObject(response.Payload.Data.Record)
                         );

                         if (recordDict.TryGetValue(columnName, out object columnValueObj) && columnValueObj != null)
                         {
                             string value = columnValueObj.ToString();
                             Debug.Log($"Column value changed to: {value}");
                             subscriptionInfo.InvokeValueChanged(value);
                         }
                     }
                     else
                     {
                         Debug.Log("Changed payload record resulted in null");
                     }
                 }
                 catch (Exception ex)
                 {
                     Debug.LogError($"Error in change handler: {ex.Message}");
                 }
             });

             await channel.Subscribe();

             activeSubscriptions[subscriptionId] = subscriptionInfo;

             Debug.Log($"Successfully subscribed to {tableName}");
             return subscriptionId;
         }
         catch (Exception ex)
         {
             Debug.LogError($"Error setting up channel: {ex.Message}");
             return null;
         }
     }
     catch (Exception e)
     {
         Debug.LogError($"Subscription setup failed: {e.Message}");
         Debug.LogError($"Stack trace: {e.StackTrace}");
         return null;
     }
 }
 
 //Usage:
    string loginTokenSub = await supabaseManager.SubscribeToTable(
       "login_tokens",
       $"token=eq.{CurrentToken}",
       "status",
       false,
       (newValue) => {
           Debug.Log($"login_tokens value changed to: {newValue}");
       }
   );

// Subscription appears successful here
Debug.Log("Successfully subscribed to login_tokens");

// If a change is made to the table immediately, it won't be recognized
// Need to wait ~4 seconds before changes are detected
Lingua principale
C#
Stelle
702
Fork
106
Merge medio
1g 20h
PR unite (30g)
66

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di supabase/supabase-csharp

Tutte le issue di supabase/supabase-csharp

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.