elixir-grpc / grpc

An Elixir implementation of gRPC
https://hex.pm/packages/grpc
Apache License 2.0
1.4k stars 214 forks source link

OTP 23/24 Support, erlang:get_stacktrace() no longer available or returns empty #203

Closed dbernheisel closed 2 years ago

dbernheisel commented 3 years ago

Is your feature request related to a problem? Please describe. Currently, grpc_stream_h.erl is using erlang:get_stracktrace() which was removed in OTP 24.

Describe the solution you'd like Looks like we need another case statement checking the OTP release and try/catch different for 24+. It was deprecated in OTP 23 and removed in OTP 24.

https://erlang.org/doc/general_info/removed.html#functions-removed-in-otp-23

https://www.erlang.org/erlang-enhancement-proposals/eep-0047.html

-ifdef(OTP_RELEASE).
-compile({nowarn_deprecated_function, [{erlang, get_stacktrace, 0}]}).
-endif.

%% ....

-spec request_process(cowboy_req:req(), cowboy_middleware:env(), [module()]) -> ok.
request_process(Req, Env, Middlewares) ->
    OTP = erlang:system_info(otp_release),
    try
        execute(Req, Env, Middlewares)
    catch
        exit:Reason ->
                         %% This is the problematic call ⬇️
            Stacktrace = erlang:get_stacktrace(),
            erlang:raise(exit, {Reason, Stacktrace}, Stacktrace);

Describe alternatives you've considered It's not an option for me to downgrade to OTP 23 or lower.

Additional context Add any other context or screenshots about the feature request here.

image

polvalente commented 2 years ago

The error handling has been updated in #224 I'll close this issue, but feel free to comment or open another one if your problem isn't solved