From bc150156ce24c74206dae6d58310d4b85fbccbec Mon Sep 17 00:00:00 2001 From: Brian Manifold Date: Wed, 26 Feb 2025 17:46:13 -0800 Subject: [PATCH] fix(portal): Update gateway channel to process resource_update (#8280) Why: * After merging #8267 it was discovered that there was a race condition that allowed a `resource_create` message to end up at the Gateway Channel process. Previously, this message would not have ever arrived, because we were replacing Resource IDs when a breaking change was made, but since that is no longer the case, it is possible that a connection could be established between the time the `delete_resource` and `create_resource` messages are sent and the `create_resource` would end up at the Gateway Channel process. This commit adds a no-op handler to make sure the message gets processed without throwing an error. --- elixir/apps/api/lib/api/gateway/channel.ex | 6 ++++++ elixir/apps/api/test/api/gateway/channel_test.exs | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/elixir/apps/api/lib/api/gateway/channel.ex b/elixir/apps/api/lib/api/gateway/channel.ex index 213dd6441..c1a88d03e 100644 --- a/elixir/apps/api/lib/api/gateway/channel.ex +++ b/elixir/apps/api/lib/api/gateway/channel.ex @@ -72,6 +72,12 @@ defmodule API.Gateway.Channel do ##### Reacting to domain events #### #################################### + # Resource create message is a no-op for the Gateway as the Resource + # details will be sent to the Gateway on an :authorize_flow message + def handle_info({:create_resource, _resource_id}, socket) do + {:norely, socket} + end + # Resource is updated, eg. traffic filters are changed def handle_info({:update_resource, resource_id}, socket) do OpenTelemetry.Ctx.attach(socket.assigns.opentelemetry_ctx) diff --git a/elixir/apps/api/test/api/gateway/channel_test.exs b/elixir/apps/api/test/api/gateway/channel_test.exs index ec85b161f..d5c8e7678 100644 --- a/elixir/apps/api/test/api/gateway/channel_test.exs +++ b/elixir/apps/api/test/api/gateway/channel_test.exs @@ -446,6 +446,15 @@ defmodule API.Gateway.ChannelTest do end end + describe "handle_info/2 :create_resource" do + test "does nothing", %{ + resource: resource, + socket: socket + } do + send(socket.channel_pid, {:create_resource, resource.id}) + end + end + describe "handle_info/2 :delete_resource" do test "does nothing", %{ resource: resource,