nats-io/nats.ex

Validate that queue_group is specified as a valid iolist entry

mmmries opened this issue · 0 comments

I was recently working on implementing an RPC server which would setup long-lived subscriptions and I was getting an error that kept crashing the Gnat connection process.

 [error] connection failed {{:badmatch, {:error, :einval}}, [{Gnat, :handle_call, 3, [file: 'lib/gnat.ex', line: 195]}, {:gen_server, :try_handle_call, 4, [file: 'gen_server.erl', line: 615]}, {:gen_server, :handle_msg, 5, [file: 'gen_server.erl', line: 647]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}

After a bunch of digging I found out that it was because I was calling Gnat.sub with queue_group: :dispatch_ex. The TCP library wouldn't serialize that atom in an iolist, it needed to be specified as a string or a charlist. This was pretty confusing to track down, and having a nice error message would have been very helpful.