Skip to content

PubSub interferes when using multiple nodes #536

@xxdavid

Description

@xxdavid

Bug Description

We have two different Phoenix applications running on different VM nodes that are connected via distributed Erlang. If we install LiveDebugger 0.3.0 into both and launch them both, the LiveDebuggers running on different nodes began to interfere.

I think it is because LiveDebugger uses Phoenix.PubSub with the static name LiveDebugger.PubSub and Phoenix.PubSub automatically connects PubSubs on connected nodes, so they start talking to each other over the nodes. If I rename the PubSub to something else in one app, everything starts to work just fine.

I suggest making the PubSub name configurable using application configuration, defaulting to LiveDebugger.PubSub. I can send a PR if wanted.

Actual Behavior

[error] GenServer LiveDebugger.GenServers.StateServer terminating
** (ArgumentError) errors were found at the given arguments:

  * 1st argument: not a local pid

    (erts 15.2) :erlang.is_process_alive(#PID<58753.845.0>)
    (live_debugger 0.3.0) lib/live_debugger/services/system/process_service.ex:52: LiveDebugger.Services.System.ProcessService.Impl.state/1
    (live_debugger 0.3.0) lib/live_debugger/gen_servers/state_server.ex:80: LiveDebugger.GenServers.StateServer.save_state/1
    (live_debugger 0.3.0) lib/live_debugger/gen_servers/state_server.ex:66: LiveDebugger.GenServers.StateServer.handle_info/2
    (stdlib 6.2) gen_server.erl:2345: :gen_server.try_handle_info/3
    (stdlib 6.2) gen_server.erl:2433: :gen_server.handle_msg/6
    (stdlib 6.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3

Expected Behavior

I would expect that LiveDebuggers running on different nodes in different applications on different ports would not interfere at all.

Steps to Reproduce

Have two apps with Phoenix LiveDebugger connected via distributed Erlang and open one of them in the browser. LiveDebugger on the other one should crash with the error above.

Elixir version with Erlang/OTP

Erlang/OTP 27 [erts-15.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit] Elixir 1.18.1 (compiled with Erlang/OTP 27)

LiveDebugger version

locked at 0.3.0 (live_debugger) afd8c013

Phoenix version

locked at 1.7.21 (phoenix) 336dce4f

Phoenix LiveView version

locked at 1.0.17 (phoenix_live_view) a4ca05c1

Operating system

macOS 15

Browser(s)

Chrome 137

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions