<div dir="ltr">Hi,<br><br>send_request and friends are unusable in their current form.<div><br>What is required would be the ability to the RequestId returned from gen_server:send_request/2 to match the returned message (for example in the header of handle_info/2 method).<br>Something like this:<br><br><font face="monospace">  Â  handle_call(Call, From, #state{other = Other} = State) -><br>  Â  Â  Â  ReqId = gen_server:send_request(Other, Call),<br>  Â  Â  Â  {noreply, State#state{pending = {ReqId, From}}}.<br><br>  Â  handle_info({ReqId, Reply}, #state{pending = {ReqId, From}} = State) -><br>  Â  Â  Â  gen_server:reply(From, Reply),<br>  Â  Â  Â {noreply, State}.</font><div><font face="monospace"><br></font></div><div><font face="arial, sans-serif">This is currently not possible, because the internal structure of the reply message is undocumented and even changed between OTP 23 and 24.</font></div><div>Currently the only way to do this would be something like this for multiple outstanding requests:</div><div><br></div><div><font face="monospace">  Â  handle_info(Msg, #state{pending1 = {ReqId1, From1}, pending1 = {ReqId2, From2}, pending1 = {ReqId3, From3}} = State) -><br>  Â  Â  Â  case check_response(Msg, ReqId1) of<br>  Â  Â  Â  Â  Â  {reply, Reply} -><br>  Â  Â  Â  Â  Â  Â  Â  gen_server:reply(From1, Reply);<br>  Â  Â  Â  Â  Â  no_reply -><br>  Â  Â  Â  Â  Â  Â  Â  case check_response(Msg, ReqId2) of<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  {reply, Reply} -><br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  gen_server:reply(From2, Reply);<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  no_reply -><br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  case check_response(Msg, ReqId3) of<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  {reply, Reply} -><br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  gen_server:reply(From3, Reply);<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  no_reply -><br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  ok<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  end<br>  Â  Â  Â  Â  Â  Â  Â  end<br>  Â  Â  Â  end.</font><br></div><div><br>This could be optimized by using a map or list for the pending requests, but it would still require one to iterate over the values and check the message against each request id.</div><div><br></div><div>Regards,</div><div>Andreas</div><div><br>-- <br>Andreas Schultz</div></div></div>