Category: Supabase and databases

Supabase Realtime: the same change appears several times in the table

Read this guide in Polish

After entering the screen several times each INSERT adds a record several times.

How to identify the source of the problem

Check if useEfect creates new channels without removingChannel in cleanup.

Compare the result for the authorized and unauthorised user, project name and exact error code.

Repair steps

Subscribe to one channel for the active view and remove it when unmounting the component.

How to Test Solution

One event gives one update of the list regardless of the number of previous entries.

Security and restrictions

Change permissions and scheme first on test data with backup. Do not put service role in your browser.