在supabase-js中运行测试脚本https://github.com/supabase/supabase/blob/master/libraries/supabase-js/test/integration/testRealtime.js
我收到间歇性的Network timeout. Still waiting...
和REALTIME DISCONNECTED
错误
当我检查服务器日志时,记录了两个错误:
127.0.0.1 - - [25/Feb/2020:17:26:17 +0000] "POST /messages HTTP/1.1" 201 - "" ""
17:26:18.082 [info] "realtime:public"
17:26:18.082 [info] "realtime:public:messages"
17:26:18.083 [info] "realtime:public:messages:channel_id=eq.1"
17:26:18.085 [error] GenServer #PID<0.2564.0> terminating
** (ArgumentError) argument error
:erlang.bit_size(nil)
(realtime) anonymous fn/3 in Realtime.Replication.notify_subscribers/1
(elixir) lib/enum.ex:789: anonymous fn/3 in Enum.each/2
(stdlib) maps.erl:232: :maps.fold_1/3
(elixir) lib/enum.ex:1964: Enum.each/2
(realtime) lib/realtime/replication.ex:237: anonymous fn/3 in Realtime.Replication.notify_subscribers/1
(elixir) lib/enum.ex:1948: Enum."-reduce/3-lists^foldl/2-0-"/3
(realtime) lib/realtime/replication.ex:217: Realtime.Replication.notify_subscribers/1
Last message: {:epgsql, #PID<0.2565.0>, {:x_log_data, 23616408, 23616408, <<67, 0, 0, 0, 0, 0, 1, 104, 91, 104, 0, 0, 0, 0, 1, 104, 91, 152, 0, 2, 66, 104, 141, 229, 100, 110>>}}
和
17:26:18.151 [info] CONNECTED TO RealtimeWeb.UserSocket in 178µs
Transport: :websocket
Serializer: Phoenix.Socket.V1.JSONSerializer
Connect Info: %{}
Parameters: %{"vsn" => "1.0.0"}
17:26:18.153 [error] GenServer #PID<0.2569.0> terminating
** (KeyError) key :record not found in: %Realtime.Adapters.Changes.DeletedRecord{columns: [%Realtime.Decoder.Messages.Relation.Column{flags: [:key], name: "id", type: "int8", type_modifier: 4294967295}, %Realtime.Decoder.Messages.Relation.Column{flags: [:key], name: "inserted_at", type: "timestamp", type_modifier: 4294967295}, %Realtime.Decoder.Messages.Relation.Column{flags: [:key], name: "updated_at", type: "timestamp", type_modifier: 4294967295}, %Realtime.Decoder.Messages.Relation.Column{flags: [:key], name: "data", type: "jsonb", type_modifier: 4294967295}, %Realtime.Decoder.Messages.Relation.Column{flags: [:key], name: "message", type: "text", type_modifier: 4294967295}, %Realtime.Decoder.Messages.Relation.Column{flags: [:key], name: "user_id", type: "int8", type_modifier: 4294967295}, %Realtime.Decoder.Messages.Relation.Column{flags: [:key], name: "channel_id", type: "int8", type_modifier: 4294967295}], commit_timestamp: ~U[2020-02-25 17:26:18Z], old_record: %{"channel_id" => "1", "data" => nil, "id" => "23", "inserted_at" => "2020-02-25 17:26:18.071593", "message" => "delete test", "updated_at" => "2020-02-25 17:26:18.071593", "user_id" => "1"}, schema: "public", table: "messages", type: "DELETE"}
(realtime) lib/realtime/replication.ex:237: anonymous fn/3 in Realtime.Replication.notify_subscribers/1
(elixir) lib/enum.ex:1948: Enum."-reduce/3-lists^foldl/2-0-"/3
(realtime) lib/realtime/replication.ex:217: Realtime.Replication.notify_subscribers/1
(realtime) lib/realtime/replication.ex:82: Realtime.Replication.process_message/2
(realtime) lib/realtime/replication.ex:54: Realtime.Replication.handle_info/2
(stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:711: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: {:epgsql, #PID<0.2570.0>, {:x_log_data, 23616632, 23616632, <<67, 0, 0, 0, 0, 0, 1, 104, 92, 72, 0, 0, 0, 0, 1, 104, 92, 120, 0, 2, 66, 104, 141, 229, 243, 123>>}}
不知道这些是否负责任,但无论如何都值得清理
有点怀疑
我认为罪魁祸首是这条线。
由于DELETE事务没有要枚举的change.record
(除非用户在postgres中设置了REPLICA IDENTITY FULL
)。 它确实有“ old_record”(我认为),所以我们也许可以枚举它
看起来挺好的。 另一个问题的补丁只是用if change.record
来包装此块
原因(我认为)是在复制开始时调用此函数,并且事务中没有实际更改。
现在让我们测试一下您的更改。 您需要我推送到docker hub吗?
最后要修复的是04:33:14.166 [error] GenServer #PID<0.2513.0> terminating
** (KeyError) key :record not found in: %Realtime.Adapters.Changes.DeletedRecord{columns: [%Realtime.Decoder.Messages.Relation.Column{flags: [:key], name: "id", type: "int8", type_modifier: 4294967295}, %Realtime.Decoder.Messages.Relation.Column{flags: [:key], name: "inserted_at", type: "timestamp", type_modifier: 4294967295}, %Realtime.Decoder.Messages.Relation.Column{flags: [:key], name: "updated_at", type: "timestamp", type_modifier: 4294967295}, %Realtime.Decoder.Messages.Relation.Column{flags: [:key], name: "data", type: "jsonb", type_modifier: 4294967295}, %Realtime.Decoder.Messages.Relation.Column{flags: [:key], name: "message", type: "text", type_modifier: 4294967295}, %Realtime.Decoder.Messages.Relation.Column{flags: [:key], name: "user_id", type: "int8", type_modifier: 4294967295}, %Realtime.Decoder.Messages.Relation.Column{flags: [:key], name: "channel_id", type: "int8", type_modifier: 4294967295}], commit_timestamp: ~U[2020-03-16 04:33:14Z], old_record: %{"channel_id" => "1", "data" => nil, "id" => "50", "inserted_at" => "2020-03-16 04:33:14.144909", "message" => "delete test", "updated_at" => "2020-03-16 04:33:14.144909", "user_id" => "1"}, schema: "public", table: "messages", type: "DELETE"}
哦,很抱歉,您刚刚已经发布了上面的修复程序,现在就可以进行更改,我测试了以前的修复程序,并且效果很好
固定在0.7.2
最有用的评论
固定在
0.7.2