-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plug request option sends messages to self #316
Comments
The messages are sent by Plug test adapter that Req uses for this: https://github.com/elixir-plug/plug/blob/v1.15.3/lib/plug/adapters/test/conn.ex#L101. My suggestion is to use things like Bypass to spawn a server for your test and hit. I’m gonna close this but please feel free to continue the discussion. |
I might be able to consume these messages in Req before returning to the caller as they are never meant to end up in the calling process. |
I am injecting the plug not in a proper test, but to simulate the remote during development of other parts, to avoid making remote calls with undesirable side effects, instead of swapping the base url and making a local endpoint. the plug seemed like a simple way to do this, but now i understand that it’s using plug test and that i’m abusing the intended purpose. of course if you can consume the messages, then i could abuse it this way. thanks for considering the possibility. |
changed dep to the 7c04 commit and this problem is resolved. Thank you! |
During development I optionally add a plug to requests to act as a loopback. The calling process is part of a GenServer. I started seeing spurious messages which I tracked down to happening somewhere in the
run_request
. The messages are 3-tuples{status, headers, response-body}
and probably come from finch sincesend
is plentiful there and none are inreq
.Maybe this is a bug, or maybe the
plug
option isn't supposed (or safe) to be used this way. If it's just unsafe, this might be a warning in the docs. If it is a bug, then I might be able extract a small sample to reproduce. Also, if plug isn't good to use for this, is there an alternative that I missed?The text was updated successfully, but these errors were encountered: