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
Trying to log request body, it logs the response instead #596
Comments
@nthx I'm seeing this as well.. |
@stve - does the report makes sense to you? |
maybe it needs request configuration too? Haven't tried that though..
|
It's a standard race condition, I think. What's happening here is that An easy fix would be to use two We don't have this bug with headers because there are two separate values there: Alternatively, make a second If this doesn't get fixed upstream soon, I'm very likely going to patch Faraday and use my own fork. I can't have unreliable logging... |
@nthx, sorry if I missed it, but which logger are you using? |
Actually, I've been using my own logger in this case. It has worked for other messages, so I didn't think it might cause an issue. |
Hi @nthx, any luck with your tests? Did you discover anything new? |
I'm going to close this assuming the fault lies on the logger as I tested the standard one and is working fine for me. @nthx feel free to reopen in case you have any new evidence pointing to Faraday as the possible cause |
I still had this bug, using the Faraday built-in Logger at the time, but I solved it by writing my own logger in middleware, and later by switching from using Faraday to something simpler. |
Hi @iMacTia, I stuck with this problem too. I have found that problem reproduced when you define adapter before logger. This code log request body: Faraday.new(url: url) do |faraday|
faraday.response :logger, ::Logger.new(STDOUT), bodies: true
faraday.adapter Faraday.default_adapter
end This don't: Faraday.new(url: url) do |faraday|
faraday.adapter Faraday.default_adapter
faraday.response :logger, ::Logger.new(STDOUT), bodies: true
end |
Hi @llxff, yes that's expected as the middlewares order is critical and adapter should always be at the bottom. @client = Saorin::Client.new(:url => @endpoint) do |connection|
connection.response :logger, @logger, :bodies => true
end I've also checked the code in |
Makes sense. I can't yet verify it again, but have another thought... I've read my initial report and it says:
Is this still the case, that there is no documentation on how actually configure logging of responses? May you please create a ticket to update the docs? Or reopen this one maybe? Also - who should contact Saorin guys? |
Hi @nthx you're very right our documentation is currently not detailed enough (actually, we're using the Readme as a "documentation"). As per Saorin, I suggest you open an issue on their page providing examples with the failing code and reporting my comment, which should help them to track down the issue. Thanks |
Hi, I've just saw this issue and I understand why my request was not well signed. We created a middleware that add a signature before making the request. The side effect was that the middleware was using the env.body to build the signature and so it was using the response body to build the signature. As I was defining the adapter at the top of the connection, my logs were also wrong and I was thinking that my signature script was also wrong. Best regards! |
Hi.
I'm trying to make 0.9.2 print both request & response bodies.
This is not documented, but discussed over in the #277 PR.
I think, I've made proper setup. I'm using Faraday via Saorin..
To my eye it looks, debug output doesn't print request body, but prints response body (not expected).
(and it follows printing response body again, as expected).
So I get sth like that in the log: (note value for
request
. It's duplicate ofresponse
actually.Check this code of
faraday/response/logger.rb
:If I read it correctly, line:
debug('request') { dump_body(env[:body]...
prints not the proper var.And, actually inspecting
env[]
, I can't find request body nowhere :-( Onlyrequest_headers
,request_options
andresponse
data.Since, I don't believe nobody noticed that before, it's probably I've made some mistake. But where?
The text was updated successfully, but these errors were encountered: