我从Supabase-Js v1升级到了v2。这样做之后,我以前工作的实时订阅都失败了,并创建了以下错误:
问题
这个错误信息意味着什么?为什么会发生错误,我如何修复它?
我认为这个表名是一个频道。
event: "phx_reply"
payload:
response: {reason: "error occurred when joining realtime:public:<table-name>"}
reason: "error occurred when joining realtime:public:<table-name>"
status: "error"
ref: "1"
topic: "realtime:public:<table-name>"
我在这里发现了类似的错误信息。不过,我不明白。虽然,我禁用了Postgres行级安全性:
https://github.com/supabase/realtime/issues/217
我的代码
您可以在这里找到完整的代码:
https://github.com/Donnerstagnacht/polity/blob/master/src/app/profile/state/profile.service.ts
表
CREATE TABLE IF NOT EXISTS public.profiles_counters
(
"id" uuid NOT NULL,
"amendment_counter" bigint DEFAULT 0::bigint,
"follower_counter" bigint DEFAULT 0::bigint,
"following_counter" bigint DEFAULT 0::bigint,
"groups_counter" bigint DEFAULT 0::bigint,
"unread_notifications_counter" bigint DEFAULT 0::bigint,
CONSTRAINT profiles_counters_pkey PRIMARY KEY (id),
CONSTRAINT profiles_counters_fkey FOREIGN KEY (id)
REFERENCES auth.users (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public.profiles_counters OWNER to postgres;
GRANT ALL ON TABLE public.profiles_counters TO anon;
GRANT ALL ON TABLE public.profiles_counters TO authenticated;
GRANT ALL ON TABLE public.profiles_counters TO postgres;
GRANT ALL ON TABLE public.profiles_counters TO service_role;
激活RealTime
begin;
drop publication if exists supabase_realtime;
create publication supabase_realtime;
commit;
alter publication supabase_realtime add table profiles_counters;
alter table "profiles_counters" replica identity full;
禁用行级安全
ALTER TABLE profiles_counters DISABLE ROW LEVEL SECURITY;
创建实时订阅
getRealTimeChangesCounters(uuid: string): RealtimeChannel {
const subscription = this.supabaseClient
.channel(`public:profiles_counters`)
.on('postgres_changes',
{
event: 'UPDATE',
schema: 'public',
table: 'profiles_counters'
},
payload => {
console.log(payload)
}
)
.subscribe()
return subscription;
发布于 2022-10-24 15:32:11
它与当前支持的内部bug有关。
我使用了基于Docker的本地开发设置。但是,supabase的停靠映像似乎落后于supabase远程版本(这是supabase文档中描述的版本)。
因此,解决方案是切换到supabase远程开发,并等待本地支持库映像的修复。
相关问题:https://github.com/supabase/realtime/issues/295 https://github.com/supabase/supabase/issues/9798
https://stackoverflow.com/questions/74175531
复制相似问题