Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/fix-supabase-realtime-multiple-filters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@refinedev/supabase": patch
---

fix(supabase): handle multiple filters in liveProvider by using only the first filter and logging a warning

Supabase Realtime only supports a single filter per subscription. When multiple filters are provided, the liveProvider will now use only the first filter and log a warning to inform developers about this limitation.

[Resolves #6360](https://github.com/refinedev/refine/issues/6360)
15 changes: 12 additions & 3 deletions packages/supabase/src/liveProvider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const liveProvider = (
return;
}

return filters
const validFilters = filters
.map((filter: CrudFilter): string | undefined => {
if ("field" in filter) {
return `${filter.field}=${mapOperator(filter.operator)}.${
Expand All @@ -63,8 +63,17 @@ export const liveProvider = (
}
return;
})
.filter(Boolean)
.join(",");
.filter(Boolean);

// Supabase Realtime only supports a single filter per subscription
// https://github.com/supabase/realtime/issues/486
if (validFilters.length > 1) {
console.warn(
`[refine/supabase]: Supabase Realtime only supports a single filter per subscription. Using the first filter: "${validFilters[0]}". Additional filters will be ignored.`,
);
}

return validFilters[0];
};

const events = types
Expand Down