Kraigie/nostrum

** (MatchError) no match of right hand side value: {:ok, :http}

Teifion opened this issue · 9 comments

Discord have (possibly just this morning) changed something and the login breaks.

I have managed to work around it by changing line 103 in ratelimiter.ex to {:ok, _} = :gun.await_up(conn_pid) but this doesn't feel like a good solution long term. I'm creating the issue in part to help people searching for it.

This issue may be resolved on the master branch.
It's related to PR #522.

Oh even better, I didn't see an open issue with this error code so I thought I might be the first person to discover it. There go my hopes at achieving internet fame!

Got the same thing I think?

** (Mix) Could not start application nostrum: Nostrum.Application.start(:normal, []) returned an error: shutdown: failed to start child: Nostrum.Api.Ratelimiter
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:ok, :http}
            (nostrum 0.5.1) lib/nostrum/api/ratelimiter.ex:42: Nostrum.Api.Ratelimiter.init/1
            (stdlib 5.0.1) gen_server.erl:962: :gen_server.init_it/2
            (stdlib 5.0.1) gen_server.erl:917: :gen_server.init_it/6
            (stdlib 5.0.1) proc_lib.erl:241: :proc_lib.init_p_do_apply/3

@mcfiredrill Yes, this is exactly the error I had. Based on the above comment you can either point to master or like I did, put a bit of a hacky solution in.

Fixed in master for me thanks @Teifion

using master didn't help at all - only introduced new problems and issues.

21:12:44.916 [debug] Establishing initial connection
21:12:44.916 [info] WAITING 5396 BEFORE NEXT SHARD CONNECT
21:12:50.341 [debug] Upgrading connection to websocket
21:12:50.421 [error] ** State machine <0.4620.0> terminating
** Last event = {info,{gun_upgrade,<0.4621.0>,
                                   #Ref<0.1875926102.2452357122.256511>,
                                   [<<"websocket">>],
                                   [{<<"date">>,
                                     <<"Sat, 21 Oct 2023 21:12:50 GMT">>},
                                    {<<"connection">>,<<"upgrade">>},

[...]

** Reason for termination = error:{'function not exported',{pg,monitor,2}}
** Callback modules = ['Elixir.Nostrum.Shard.Session']
** Callback mode = [state_functions,state_enter]
** Stacktrace =
**  [{'Elixir.Nostrum.Shard.Session',connected,3,
                                     [{file,"lib/nostrum/shard/session.ex"},
                                      {line,234}]},
     {gen_statem,loop_state_callback,11,[{file,"gen_statem.erl"},{line,1419}]},
     {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]

Using master is the fix for the match errors above.

For the later error

** Reason for termination = error:{'function not exported',{pg,monitor,2}}

You need to upgrade to OTP 25.1 or above, where :pg.monitor was introduced. https://www.erlang.org/doc/man/pg#monitor-2

FlXlT commented

This bug is a breaking change to Nostrum and should be hotfixed or at least put in a new version 0.8.1. That is more reliable than to change one's dependency version back to {:nostrum, github: "Kraigie/nostrum"} or implementing a downgrade.

This bug is a breaking change to Nostrum and should be hotfixed or at least put in a new version 0.8.1. That is more reliable than to change one's dependency version back to {:nostrum, github: "Kraigie/nostrum"} or implementing a downgrade.

PR's welcome