skills/realtime-rls-debugging/SKILL.md
Debugging Supabase Realtime subscriptions that connect but deliver no updates, empty filter errors, and RLS silent-rejection diagnosis. Use when Realtime subscriptions are not delivering messages or updates.
npx skillsauth add bkinsey808/songshare-effect realtime-rls-debuggingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Requires: file-read, terminal (Supabase CLI/SQL). No network access needed.
Use this skill when:
Execution workflow:
Output requirements:
SUBSCRIBED but UPDATE/INSERT messages never fireError parsing filter params: [""] in Supabase logs-- 1. Is RLS enabled?
SELECT relname, relrowsecurity FROM pg_class WHERE relname = 'event_public';
-- 2. List all policies on the table
SELECT policyname, permissive, roles, qual, with_check
FROM pg_policies
WHERE schemaname = 'public' AND tablename = 'event_public'
ORDER BY policyname;
-- 3. Simulate what Realtime sees for a JWT
SET ROLE authenticated;
SET app.jwt = '<paste-jwt>';
SELECT * FROM public.event_public WHERE event_id = '<test-id>';
-- 0 rows → RLS is blocking this token
-- 4. Confirm Realtime is publishing this table
SELECT schemaname, tablename
FROM pg_publication_tables
WHERE pubname = 'supabase_realtime';
If the table is missing from pg_publication_tables, enable it: Supabase dashboard → Database → Replication → toggle table.
grep -r 'filter: ""' react/src --include="*.ts" --include="*.tsx"
Supabase cannot parse filter: "". Either remove the key entirely or provide a valid value:
// ❌ Filter error
channel.on("postgres_changes", { event: "UPDATE", table: "user_public", filter: "" }, cb);
// ✅ Omit filter (all rows) or provide valid expression
channel.on(
"postgres_changes",
{ event: "UPDATE", table: "event_public", filter: `event_id=eq.${eventId}` },
cb,
);
channel.on("system", { event: "error" }, (payload: unknown) => {
if (isRecord(payload) && payload["status"] !== "ok") {
console.error("Realtime error:", payload);
}
});
Catches parsing errors, auth failures, and RLS rejections that are otherwise silent.
Decode your JWT in DevTools:
const [, b64] = token.split(".");
console.log(JSON.parse(atob(b64)));
// Check: app_metadata.visitor_id OR app_metadata.user.user_id
Then run the Step 3 SQL simulation above. If SELECT returns 0 rows, the RLS policy is blocking this JWT.
SELECT policyname, qual
FROM pg_policies
WHERE schemaname = 'public' AND tablename = 'event_public' AND policyname LIKE '%read%';
Common mistakes:
{ user_id: "..." } at root instead of inside app_metadata)WITH CHECK clause blocks the UPDATE/change notification rowMost likely RLS is silently filtering the subscriber. Confirm with the SQL simulation (Step 4), then verify the SELECT policy includes both visitor and user JWT paths. See realtime-rls-architecture skill for the verified production policy templates.
Decode both JWTs and compare structures. Check whether both visitor_id and user.user_id paths are handled in the policy USING clause.
npm run lint
npm run test:unit
Manual two-tab smoke test:
active_song_id in Tab Asupabase/migrations/20260220000011_re_enable_rls_on_event_public.sqldocs/ai/rules.md.realtime-rls-architecture.authentication-system.tools
Zustand state management patterns for this project — store creation, selectors, Immer middleware, async actions with loading states, devtools, persist, and testing. Use when authoring or editing Zustand stores (use*Store files) or components that subscribe to stores. Do NOT use for React component structure or TypeScript-only utilities.
testing
How to write, update, or split skill files in this repo. Use when creating a new SKILL.md, updating an existing one, or deciding whether to put content in a skill vs. docs/.
development
Complete guide for testing React hooks — renderHook, Documentation by Harness, installStore, fixtures, subscription patterns, lint/compiler traps, and pre-completion checklist. Read docs/testing/unit-test-hook-best-practices.md for the full reference.
development
Vitest unit test authoring for this repo — setup, mocking, API handler testing, and common pitfalls for non-hook code. Use when the user asks to add, update, fix, or review unit tests for utilities, components, API handlers, or scripts. Do NOT use for React hook tests — load unit-test-hook-best-practices instead.