Realtime not working properly

I have a simple subscription, but it only works like 60% the time. I have not yet been able to identify the specific cases where it fails, as of now it just seems to be random
Here's the code
 const mySubscription = supabase
  .from('testlist')
  .on('*', (payload) => {
    console.log('Change received!', payload)
    if (payload.eventType === "INSERT") {
      datalist = [...datalist, payload.new]
    } 
    if (payload.eventType === "DELETE") {
      console.log(datalist.indexOf(payload.old))
      removeFromDataList(payload.old.id)
      console.log(datalist)
      datalist = datalist
    }
    
  })
  .subscribe()
Was this page helpful?